$N$ pirates put their treasure in a chest. The pirates do not trust each other (with good reason!), so they consult a locksmith. The locksmith puts $L$ locks on the chest, and every lock must be unlocked before the chest can be opened. He then hands out keys so that every pirate holds some, but not all, of the keys. A single lock may have several keys, but each key opens exactly one lock.
Given the number of pirates and the set of keys each pirate holds, find every group of pirates that can together open the chest but contains no unnecessary members. In other words, if any pirate is removed from the group, the chest can no longer be opened.
There are far too many pirates to simply try every possible combination, so you will need to choose a smarter algorithm.
The first line contains the number of pirates $N$ and the number of locks $L$. Each of the next $N$ lines describes one pirate: the $i$-th of these lines lists, separated by spaces, the numbers of the locks that pirate $i$ holds keys to. Pirates are numbered from $1$ to $N$, and locks are numbered from $1$ to $L$.
Print every group of pirates that can open the chest with no unnecessary members. Print each group on its own line, listing the pirates in increasing order. List the groups from the fewest pirates to the most; groups with the same number of pirates are listed in lexicographic order (compare the first pirate, breaking ties by the second, then the third, and so on).