I need to reset my 3g phone to fractory settings and unlock it.
Via iTunes > Restore
Or iPhone > Settings > General > Reset > Reset and erase all.
Settings > General > Reset > Reset All Settings
This won't erase the data.
As for the unlocking, only your carrier can do that.
> erase all content and settings.
Yes, everything will be erased.
Retrieving data ...