#include <bits/stdc++.h>
using namespace std;
int n, s[1005][1005], len;
int main() {
  scanf("%d", &n);
  int a;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a);
      if (a == -1) continue;
      int w = 0;
      while (a) {
        w++;
        if (a % 2 == 1) s[i][w] = s[j][w] = 1;
        a /= 2;
      }
      len = max(len, w);
    }
  for (int i = 1; i <= n; i++) {
    int p = 0;
    for (int j = len; j >= 1; j--) p = p * 2 + s[i][j];
    printf("%d ", p);
  }
  printf("\n");
  return 0;
}
