pairmatch function

Optimal 1:1 and 1:k matching