#include <bits/stdc++.h>
int a[102];
int main() {
  int n, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", &b);
      if (i == j) continue;
      for (int k = 0; b; k++, b >>= 1) {
        if (b & 1) {
          a[i] |= 1 << k;
          a[j] |= 1 << k;
        }
      }
    }
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    printf("%d", a[i]);
  }
  puts("");
  return 0;
}
