I have a brilliant solution but its not for the faint hearted or most likely the intelligent.
Get an unlocked iPhone and then get another locked iPhone, solder the unlocked chips off locked one and re-solder them on the unlocked one, now get other chips off unlocked iPhone and solder them on locked iPhone, WAIT.
Try again, get iPhone thats locked and get another thats unlocked now concentrate and stop messing around.
Desolder chips from perfectly good working iPhone 5 therefore breaking it and solder them on the other iPhone that is broken therefore making it unbroken.
Magic solution, pick up unlocked iPhone in left hand and now concentrate as this is very difficult part, pick up locked iPhone in right hand, put contents of left hand in right hand and contents of right hand in left hand now in left hand you have locked iPhone and in right hand you have unlocked iPhone.
(Some people are Otters, some people are Rocks)