#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using std::bitset;
using namespace std;
int b[110][110], a[110];
int n;
int main() {
  int i, j, tem;
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) scanf("%d", &b[i][j]);
    memset(a, 0, sizeof(a));
    ;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++)
        if (j != i) a[i] |= b[i][j];
    }
    for (i = 1; i < n; i++) printf("%d ", a[i]);
    printf("%d\n", a[n]);
  }
  return 0;
}
