Strange Tournament#2477

Strange Tournament

1 second
64 megabytes
Very hard

participants played a round-robin table tennis tournament, in which each participant played exactly one match against every other participant. There were no draws in this tournament.

The tournament is called -strange if there exists a "strange" chain of distinct participants A_1, A_2, \ldots, A_K, such that A_1 defeated A_2, A_2 defeated A_3, and so on, A_{K-1} defeated A_K, and A_K defeated A_1. For each from to , write a program that determines whether the tournament is -strange. If it is, construct a corresponding "strange" chain of length .

Input

The input file starts with the number (3 \leq N \leq 300). Then the results of the matches are listed. Each match is described by two numbers: the first is the number of the player who won, and the second is the number of the player who lost. Each match result appears exactly once in the input file.

Output

The output file should contain exactly N-2 lines. In the -th line, write the answer for K = i+2. For each , output numbers—the indices of the members of a "strange" chain A_1, A_2, \ldots, A_K, separated by spaces. If there is no -strange chain, output for all these numbers.

Examples

Example 1

Loading
Loading