note
saberworks
I asked a very similar question in the past, check it out:
[id://325451]
There were two modules posted in the comments there that do this exact thing. And they can do a recursive solution, so you can have an arbitrary number of sets.
486914
486914