# List maximum number of three-sets

Suppose i'm given with pairs component-quantity. I need to list maximum number of possible three-sets.

{AA}, {BB}, {C}, {D} => {ABC},{ABD}.


To list two-sets it is possible to use maximum matching algorithm, but with three-sets i'm stuck. Prof of NP-comlexity also works for me.