Suppose A has M distinct objects.

And suppose B has N objects with k distinct groups with ni objects in the ith distinct group. ( so sum(i=0,k){ni}=N )

Case 1

M >= N (so matches have N pairs each)

There are M!/(N!(M-N)!) order independent ways of choosing N elements from A

There are N!/(n1!n2!..nk!) order dependent ways of choosing the N elements of B

Each match will be a combination of an order independent choice of A and an order dependent choice of B

Total= ( M!/(N!(M-N)!) )*( N!/(n1!n2!..nk!) )

Case 2

M < N (so matches have N pairs each)

this is trickier and am thinking.