#P442. 练77.1 队列复原

练77.1 队列复原

Description

Xiaogua has arranged the integers from 11 to nn in a sequence, but he only tells you what number comes after each integer (the number after the last integer is 00). Please help restore the complete sequence.

Input Format

The first line contains an integer nn (n100000n\le 100000), indicating there are nn integers. The next nn lines each contain two numbers ii,jj, indicating that the number after integer ii is jj.

Output Format

nn lines, each containing one integer, representing the complete sequence.

Sample

3
1 2
2 3
3 0
1
2
3