#include <bits/stdc++.h>
using namespace std;
int ar[101][101], br[101];
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &ar[i][j]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      int e = ar[i][j];
      int k = 0;
      while (e) {
        bool z = e & 1;
        if (z) {
          br[i] |= (1 << k);
          br[j] |= (1 << k);
        }
        e >>= 1;
        k++;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", br[i]);
  printf("\n");
}
signed main() {
  solve();
  return 0;
}
