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_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.

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms

Constructive algorithms


Solutions:
n = int(input())
p = [0] * n
for i in range(n):
	t = list(map(int, input().split()))
	t.pop(i)
	s = 0
	for j in t:
		s |= j
	p[i] = s
print(' '.join(map(str, p)))


n = int(input())
if n > 1:
	p = [0] * n
	r = format(n - 1, 'b')[::-1]
	l = len(r) - 1
	for i in range(n):
		t = list(map(int, input().split()))
		t.pop(i)
		s = 0
		for j in range(l):
			if r[j] == '1':
				s |= t.pop()
			t = [t[k] | t[k + 1] for k in range(0, len(t), 2)]
		p[i] = s | t[0]
	print(' '.join(map(str, p)))
else:
	print(0)


n = int(input())
A = [0] * n
ans = [0] * n
for i in range(n):
	A[i] = list(map(int, input().split()))
	for j in range(n):
		if j == i:
			continue
		ans[i] |= A[i][j]
for i in range(n):
	print(ans[i], ' ', end='')


n = int(input())
if n == 1:
	print(0)
else:
	m = [[0] * n] * n
	a = [int(0)] * n
	for i in range(0, n):
		m[i] = input().split()
		a[i] = int(m[i][(i + 1) % n])
		for j in range(0, n):
			if j != i:
				a[i] = a[i] | int(m[i][j])
	for i in range(0, n):
		print(a[i], end=' ')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = [0] * n
for i in range(n):
	for j in range(n):
		if j != i:
			ans[i] |= a[i][j]
	print(ans[i], end=' ')


n = int(input())
a = [0] * n
for i in range(n):
	for x in map(int, input().split()):
		if x != -1:
			a[i] |= x
print(*a)