First, apologies for the title. This is an odd question, and I couldn't come up with a simple title for it. I'm trying to come up with a good algorithm for the following, and it's giving me a headache. I have (not necessarily disjoint) sets $S_1,\ldots,S_T$, each $S_t$ contains a subset of $1,\ldots,N$ for some $N$. I want to generate all possible objects, where an object is defined as a set of $k$ tuples of length $T$, with each tuple in an object containing exactly one element from each of $S_1,\ldots,S_T$ and in each object no base element from $1,\ldots,N$ is repeated. For example: $k = 3, T = 2, N = 6$. $S_1 = \{1,2,4,5\}$ $S_2 = \{2,3,4,6\}$ One valid object would be $O_1 = (1,2),(4,3),(5,6)$ - all six numbers appear and each pair has one element from $S_1$ and one element from $S_2$. EDIT: I had before that $O_1 = (1,2),(3,4),(5,6)$. This was incorrect. An invalid object would be $(1,5),(2,4),(3,6)$, since $1 \in S_1$ but $5 \notin S_2$. The reason I'm interested in this is because these valid objects are feasible solutions for a problem I'm working on, and I'd like to enumerate all feasible solutions on small test cases to get some intuition on my problem.