This is the possible sources of both codes.
P0171
Air Measurement System :
MAF sensor (contaminated, damaged, malfunctioning, etc.)
Fuel System:
Fuel pressure regulator (leaking, malfunctioning, etc.).
Fuel filter plugged, dirty.
Fuel pump (weak, check valve leaking, etc.).
Leaking/contaminated fuel injectors.
Low fuel pressure or running out of fuel.
EVAP canister purge valve leaking (when canister is "clean").
Fuel supply line restricted.
Fuel rail pressure sensor (incorrect reading).
Air Induction System:
Air leaks after the MAF.
Vacuum leaks.
PCV system (leak, valve stuck open, etc.)
Improperly seated engine oil dipstick.
Air induction turbulence due to incorrect air filter.
Exhaust System
Exhaust leaks before or near the HO2Ss (exhaust manifold gasket, mating gaskets, etc.).
EGR System:
EGR valve tube/gasket leak
EVR solenoid vacuum leak
Secondary Air Injection:
Damaged/malfunctioning secondary air injection system (mechanically stuck valve).
P1131
Electrical:
Short to VPWR in harness or HO2S
Water in harness connector
Open/Shorted HO2S circuit
Corrosion or poor mating terminals and wiring
Damaged HO2S
Damaged PCM
Fuel System:
Excessive fuel pressure
Leaking/contaminated fuel injectors
Leaking fuel pressure regulator
Low fuel pressure or running out of fuel
Vapor recovery system
Induction System:
Air leaks after the MAF
Vacuum Leaks
PCV system
Improperly seated engine oil dipstick
EGR System:
Leaking gasket
Stuck EGR valve
Leaking diaphragm or EVR
Base Engine:
Oil overfill
Cam timing
Cylinder compression
Exhaust leaks before or near the HO2S(s)