#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000000000000000LL;
const double EPS = 1e-9;
const long long mod = 1000000007ll;
const int maxn = (int)105 + 10;
int a[maxn][maxn];
int ret[maxn];
int n;
int te[maxn][maxn];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j) scanf("%d", &a[i][j]);
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j)
      if (i != j) ret[i] |= a[i][j];
  for (int i = 0; i < (int)(n); ++i) printf("%d ", ret[i]);
}
