Maze reduction

No attempts yetTime limit2sMemory limit128 MB

Problem

Jay runs a carnival maze made of circular rooms linked by narrow, twisty corridors. Rooms A and B are effectively identical if, knowing the full map, an explorer dropped into A or B cannot tell which room they started in. Corridor exits are evenly spaced around each room, nothing can be marked inside a room, and corridors look the same. The only cues are the number of exits and, after entering through one corridor, the clockwise order of the other exits. Print every maximal set of effectively identical rooms.

Input

A single test case. The first line contains nn (1n1001 \le n \le 100), the number of rooms numbered from 11 to nn. Each of the next nn lines describes one room: an integer kk (0k<1000 \le k < 100), the number of corridors, followed by kk distinct room numbers listed in clockwise order from an arbitrary starting exit. No room connects to itself.

Output

For each maximal set of effectively identical rooms with size at least 22, print the room numbers in increasing order on one line. Order the lines by the smallest room number in each set. If no such set exists, print none.