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