Sorting

No attempts yetTime limit1sMemory limit1024 MB

Problem

Jonas and Artūras are playing a game. Jonas lays out two rows of cards, each row containing NN cards. Every card has an integer between 11 and NN written on it, and within a single row each value from 11 to NN appears exactly once — so each row is a permutation of 1,2,,N1, 2, \dots, N.

Artūras cannot see the numbers. To learn them, he compares cards across the two rows: he picks one card from the first row and one card from the second row and asks Jonas which of the two values is larger. Jonas replies that the first card is larger, that the second card is larger, or that the two cards are equal.

Artūras has already compared every card of the first row against every card of the second row and recorded all of the answers as a table. Let the result of comparing the ii-th card of the first row with the jj-th card of the second row be the integer ri,jr_{i,j}:

  • ri,j=1r_{i,j} = 1 if the first row's card is larger,
  • ri,j=1r_{i,j} = -1 if the second row's card is larger,
  • ri,j=0r_{i,j} = 0 if the two cards are equal.

Given the whole table, determine the integer written on every card in both rows.

Input

The first line contains one integer NN — the number of cards in each row.

Each of the next NN lines contains NN integers. The jj-th integer on the ii-th of these lines is ri,j{1,0,1}r_{i,j} \in \{-1, 0, 1\}, the comparison result between the ii-th card of the first row and the jj-th card of the second row.

Output

Print two lines.

  • The first line contains the NN values written on the cards of the first row, in order, separated by single spaces.
  • The second line contains the NN values of the second row, in the same format.

The answer is uniquely determined by the input.

Constraints

  • 1N2001 \le N \le 200
  • Every comparison result satisfies ri,j{1,0,1}r_{i,j} \in \{-1, 0, 1\}.
  • The table is always consistent with two permutations of 1,2,,N1, 2, \dots, N, so a valid answer exists and is unique.