#include <bits/stdc++.h>
void fileio_in_out() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
void fileio_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int n, m, ans = 0;
int i, j, k, l;
int a[1111111];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    a[i] = 0;
    for (j = 1; j <= n; j++) {
      scanf("%d", &m);
      if (i != j) a[i] |= m;
    }
  }
  for (i = 1; i < n; i++) printf("%d ", a[i]);
  printf("%d\n", a[n]);
  return 0;
}
