#include <bits/stdc++.h>
int a[110][110], num[110][40];
void conv(int i, int j, int num);
void cal(int ind);
int main() {
  int i, j, k, l, test, t = 1, n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
      if (i == j) continue;
      conv(i, j, a[i][j]);
    }
  }
  for (i = 1; i <= n; i++) {
    if (i > 1) printf(" ");
    cal(i);
  }
  return 0;
}
void cal(int ind) {
  int i, j, k, l;
  int val = 0;
  for (i = 30; i >= 0; i--) {
    val *= 2;
    if (num[ind][i] == 1) val++;
  }
  printf("%d", val);
}
void conv(int i, int j, int numb) {
  int k, l;
  k = 0;
  while (numb) {
    l = numb % 2;
    if (l == 1) {
      num[i][k] = 1;
      num[j][k] = 1;
    } else {
      if (num[i][k] == 1) num[j][k] = 2;
      if (num[j][k] == 1) num[i][k] = 2;
    }
    k++;
    numb /= 2;
  }
}
