Exporting relationships
Have you tried Reports > Contact Reports > Relationships? The contact IDs of both Contacts A and B are concatenated with the name in parenthesis, and you also have the option to add the contact ID for Contact A as a column as well as other fields you might need.

Hope this helps,
Tamar