I do not think that there can be an answer to such a vague question.
If the example you gave is the actual question then you must look at all the cases where the different collections have non-empty intersections.
For example, you can select any elements from the first two.
But then as you move to group 3, you must consider if from group 2 you have selected 5 or 29 then that restricts what you can pick in group 3.
So fourth and so on.
Short of having actual data sets, I see no way of giving a general solution.