Game with Cards#4962

Game with Cards

1 second
128 megabytes
Very easy

Tyomitch plays the following game with of his friends. Tyomitch leaves the room. His friends write numbers from to on cards, and each of the friends takes a card in a way that Tyomitch doesn't know which card each one has. Let's number the friends from to . After Tyomitch comes back to the room, each of his friends makes statements of the following form (examples given for 'th friend):

  1. I have the card number a_i.

  2. b_i'th friend has the card number c_i (b_i \neq ).

Exactly one of these statements is true, and the other one is false. It's known that no two friends said that friend has card , and nobody said that friend has card if admitted that he has this very card. The task for Tyomitch is to determine for each of his friends which of his statements is true.

Input

The first line of the input contains the number (2 \le n \le 1000). Each of the following lines contains a triple a_i, b_i, c_i - the statements of Tyomitch's friends.

Output

The only line of output must contain numbers separated with spaces, being the numbers of the true statement (either or ) for each of the friends. It is known that a solution exists.

Examples

Example 1

Loading
Loading