#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int a[maxn], b[maxn][maxn], n, B[maxn][maxn];
int main() {
  int i, j, p, flag;
  while (~scanf("%d", &n)) {
    if (n == 1) {
      scanf("%d", &flag);
      printf("0\n");
      continue;
    }
    memset(b, 0, sizeof(b));
    memset(a, 0, sizeof(a));
    memset(B, 0, sizeof(B));
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) scanf("%d", &b[i][j]);
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) {
        if (i != j) {
          a[i] += (b[i][j] - (b[i][j] & a[i]));
          a[j] += (b[i][j] - (b[i][j] & a[j]));
        }
      }
    for (i = 1; i <= n; i++) {
      if (i == 1)
        printf("%d", a[i]);
      else
        printf(" %d", a[i]);
    }
    printf("\n");
  }
  return 0;
}
