Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

D. Restoring Table

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputRecently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.

For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative integers *a*_{1}, *a*_{2}, ..., *a*_{n}. He also wrote a square matrix *b* of size *n* × *n*. The element of matrix *b* that sits in the *i*-th row in the *j*-th column (we'll denote it as *b*_{ij}) equals:

- the "bitwise AND" of numbers
*a*_{i}and*a*_{j}(that is,*b*_{ij}=*a*_{i}&*a*_{j}), if*i*≠*j*; - -1, if
*i*=*j*.

Having written out matrix *b*, Polycarpus got very happy and wiped *a* off the blackboard. But the thing is, the teacher will want this sequence to check whether Polycarpus' calculations were correct. Polycarus urgently needs to restore the removed sequence of integers, or else he won't prove that he can count correctly.

Help Polycarpus, given matrix *b*, restore the sequence of numbers *a*_{1}, *a*_{2}, ..., *a*_{n}, that he has removed from the board. Polycarpus doesn't like large numbers, so any number in the restored sequence mustn't exceed 10^{9}.

Input

The first line contains a single integer *n* (1 ≤ *n* ≤ 100) — the size of square matrix *b*. Next *n* lines contain matrix *b*. The *i*-th of these lines contains *n* space-separated integers: the *j*-th number represents the element of matrix *b*_{ij}. It is guaranteed, that for all *i* (1 ≤ *i* ≤ *n*) the following condition fulfills: *b*_{ii} = -1. It is guaranteed that for all *i*, *j* (1 ≤ *i*, *j* ≤ *n*; *i* ≠ *j*) the following condition fulfills: 0 ≤ *b*_{ij} ≤ 10^{9}, *b*_{ij} = *b*_{ji}.

Output

Print *n* non-negative integers *a*_{1}, *a*_{2}, ..., *a*_{n} (0 ≤ *a*_{i} ≤ 10^{9}) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces.

It is guaranteed that there is sequence *a* that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.

Examples

Input

1

-1

Output

0

Input

3

-1 18 0

18 -1 0

0 0 -1

Output

18 18 0

Input

4

-1 128 128 128

128 -1 148 160

128 148 -1 128

128 160 128 -1

Output

128 180 148 160

Note

If you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/24/2017 07:13:55 (c4).

Desktop version, switch to mobile version.
User lists

Name |
---|