#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int num[103][103];
int dist[103], vis[103];
int n;
void spfa() {
  int a, b, i, j;
  queue<int> q;
  for (i = 1; i <= n; i++) {
    dist[i] = 0;
    for (j = 1; j <= n; j++) {
      if (i == j) {
        continue;
      }
      dist[i] |= num[i][j];
    }
    q.push(i);
    vis[i] = 1;
  }
  while (!q.empty()) {
    a = q.front();
    q.pop();
    vis[a] = 0;
    for (i = 1; i <= n; i++) {
      if (i == a) {
        continue;
      }
      if ((dist[a] & dist[i]) != num[a][i]) {
        dist[i] |= num[a][i];
        dist[a] |= num[a][i];
        q.push(a);
        vis[a] = 1;
        if (vis[i] == 0) {
          q.push(i);
          vis[i] = 1;
        }
      }
    }
  }
}
int main() {
  cin >> n;
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      scanf("%d", &num[i][j]);
    }
  }
  spfa();
  for (i = 1; i <= n; i++) {
    printf("%d ", dist[i]);
  }
  putchar(10);
  return 0;
}
