You should have backed up your iPhone B contacts to your laptop via something like copytrans contacts
- before you synced with iTunes.
iTunes automatically creates a backup of your contacts and other iPhone data such as notes and calendars upon sync - problem is you can only restore this via a factory-settings restore.
Now the only thing to do is to restore your iPhone B with iTunes to factory settings. When iTunes prompts you if you want to restore a previous backup - select the backup from the date which your iPhone B's contacts got wiped by iTunes. This will restore your original iPhone B contacts on your iPhone B and delete your iPhone A contacts from there.
Finally, use the program I mentioned above in order to:
1. Create a backup of both your iPhone A and B contacts to your computer
2. Transfer your iPhone A contacts and add them to your iPhone B without deleting the contacts existing on iPhone B