http://codeforces.com/problemset/problem/245/D


/*30ms,0KB*/

#include<bits/stdc++.h>
using namespace std;
const int mx = 105;

int m[mx][mx],a[mx];

int main()
{
	int n, i, j;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i)
		for (j = 1; j <= n; ++j)
			scanf("%d", &m[i][j]);
	for (i = 1; i <= n; ++i)
		for (j = 1; j <= n; ++j)
			if (j != i) a[i] |= m[i][j];
	printf("%d", a[1]);
	for (i = 2; i <= n; ++i)
		printf(" %d", a[i]);
	putchar(10);
	return 0;
}