Problem E. Implicit array

Author:М. Спорышев   Time limit:1 sec
Input file:input.txt   Memory limit:256 Mb
Output file:output.txt  

Statement

Sorted array of integers is represented implicitly. Instead of each element, a set of that element and its neighbors on the right and on the left is known. First and last array elements have no more than one neighbor. Note that the set does not represent neither the order of elements nor duplicate values.

Your program must output explicit representation of the array (all elements in order).

Input file format

First line of input file contains integer N — number of elements in array.

Following N lines contain implicit representation of array elements: set size si and si different integers aij — a set of i-th array element and its neighbors.

Output file format

Output file must contain N integers — elements of original sorted array.

Constraints

1 ≤ N ≤ 105

 − 109 ≤ aij ≤ 109

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
7
1 1
1 1
2 1 2
2 1 2
2 2 3
2 2 3
1 3
1 1 1 2 2 3 3
2
1
1 7
7

0.109s 0.017s 15