404996: GYM101733 B Permutation Recovery

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Permutation Recoverytime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

Vladislav invented a new algorithm of the distributed key construction.

The distributed key consists of 2n numerical sequences of length n. To construct the key Vladislav gets some permutation p of length n2. Next step is to put the elements of p into a square matrix a. The first n elements of p form the first row of a, next n elements form the second row, etc. Finally, 2n numerical sequences of the distributed key are rows and columns of the matrix a.

These 2n sequences were given to Vladislav in some arbitrary order. He spent a while trying to come up with an algorithm for recovering the permutation. Try to restore the permutation before the end of the round!

Input

The first input line contains one integer n (1 ≤ n ≤ 100).

Each of the next 2n lines contains n integers from 1 to n2, rows and columns of the matrix a in some order.

It is guaranteed that the input is correct, there is at least one suitable permutation p.

Output

Print a permutation p of integers from 1 to n2.

ExamplesInput
2
1 2
1 3
2 4
3 4
Output
1 2 3 4
Input
4
1 6 14 7
5 4 1 13
13 16 12 10
8 3 6 16
11 2 7 10
15 9 14 12
4 3 9 2
5 8 15 11
Output
5 4 1 13 8 3 6 16 15 9 14 12 11 2 7 10

加入题单

上一题 下一题 算法标签: