#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 105;
int ans[MAXN][40];
int a[MAXN][MAXN];
int n;
void solved(int cas) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (int k = 0; k <= 30; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (i != j && (a[i][j] & (1 << k))) ans[i][k] = ans[j][k] = 1;
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    int temp = 0;
    for (int k = 0; k < 30; k++) temp |= ans[i][k] << k;
    printf("%d", temp);
  }
  printf("\n");
}
int main() {
  int T = 1;
  for (int i = 1; i <= T; i++) solved(i);
  return 0;
}
