#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, a[110];
  int g[110][110];
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &g[i][j]);
  if (n == 1) {
    printf("0\n");
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (i != j) {
        a[i] = g[i][j];
        break;
      }
    for (int j = 0; j < n; j++)
      if (i != j) a[i] |= g[i][j];
  }
  for (int i = 0; i < n; i++) printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
}
int main() {
  solve();
  return 0;
}
