#include <bits/stdc++.h>
int n;
int i, j, k;
int a[101];
int b[101][101];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++) {
      a[i] = 0;
      for (j = 1; j <= n; j++) scanf("%d", &b[i][j]);
    }
    for (i = 1; i <= n; i++)
      for (j = i + 1; j <= n; j++) {
        a[i] |= b[i][j];
        a[j] |= b[i][j];
      }
    for (i = 1; i <= n; i++)
      if (i == n)
        printf("%d\n", a[i]);
      else
        printf("%d ", a[i]);
  }
  return 0;
}
