#include <bits/stdc++.h>
using namespace std;
int t[150][150], a[150];
int main() {
  int i, j, n;
  while (cin >> n) {
    memset(a, 0, sizeof(a));
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) scanf("%d", &t[i][j]);
    if (n == 1) {
      printf("0\n");
      continue;
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        if (i == j) continue;
        a[i] = a[i] | t[i][j];
      }
    }
    for (i = 1; i <= n; i++) {
      printf("%d", a[i]);
      if (i != n)
        printf(" ");
      else
        printf("\n");
    }
  }
  return 0;
}
