Recently 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*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. 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*<sub class="lower-index">*ij*</sub>) equals:
 -  the "bitwise AND" of numbers *a*<sub class="lower-index">*i*</sub> and *a*<sub class="lower-index">*j*</sub> (that is, *b*<sub class="lower-index">*ij*</sub> = *a*<sub class="lower-index">*i*</sub> &amp; *a*<sub class="lower-index">*j*</sub>), 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*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>, that he has removed from the board. Polycarpus doesn't like large numbers, so any number in the restored sequence mustn't exceed 10<sup class="upper-index">9</sup>.
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*<sub class="lower-index">*ij*</sub>. It is guaranteed, that for all *i* (1 ≤ *i* ≤ *n*) the following condition fulfills: *b*<sub class="lower-index">*ii*</sub> = -1. It is guaranteed that for all *i*, *j* (1 ≤ *i*, *j* ≤ *n*; *i* ≠ *j*) the following condition fulfills: 0 ≤ *b*<sub class="lower-index">*ij*</sub> ≤ 10<sup class="upper-index">9</sup>, *b*<sub class="lower-index">*ij*</sub> = *b*<sub class="lower-index">*ji*</sub>.
from sys import stdin
import math
import zlib

n = int(stdin.readline().rstrip())
m = [list(map(int, stdin.readline().rstrip().split(' '))) for _ in range(n)]

ans = [0] * 110
for i in range(n):
    for j in range(n):
        if i != j:
            ans[i] |= m[i][j]

for i in range(n):
    print(ans[i], end=' ')