The 171 & 174 codes both refer to a lean fuel mixture; the 300 and 316 codes both refer to misfiring (which would be caused by an excessively lean fuel mixture).
A clogged fuel filter is one of the most likely items to cause these codes. They could also be caused by a mass airflow sensor or throttle body which needs cleaning. Other items which could cause these codes are vacuum leaks in hoses, disconnected PCV hose or improperly routed vacuum lines, emission controls which have been bypassed, a defective throttle position sensor, fuel pump or fuel pressure regulator, or an EGR valve which is not closing completely. If you installed spark plugs which are too cold for this motor, or did not use double platinum or iridium plugs, or did not set the gap to the recommended .054" setting; that could also cause this problem. The correct spark plugs for this motor depend on the engine type:
The 4.6 liter V-8 (VIN code "W") can use either Autolite # APP104, Champion # 7963, Denso # 5070, or NGK # 6579.
Both of the 4.0 liter V-6 motors (VIN code "E" or "K") should use either Autolite # XP103, Champion # 7963, Denso # 5070, or NGK # 6579.
The factory recommended Autolite plug is the only one which changes between the two engine sizes.
The price for these services will vary considerably in different parts of the country; as well as between different shops in the same community. Because of that; the best way to get a sense of the cost would be to phone several local garages, tell them what you want done, and compare their estimates. You may be able to do some of these things yourself, which would eliminate the labor costs; but I would not attempt any unfamiliar procedures without first becoming thoroughly familiar with the tools, techniques and chemicals required.
After the repairs are done; the codes will have to be cleared from the computer with a scan tool.