#include <bits/stdc++.h>
using namespace std;
inline int readint() {
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
inline long long readlong() {
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  long long x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
int mat[30][105][105];
int brr[105][105];
int arr[30][105];
int bits[30];
int n;
void turnto(int val) {
  for (int i = 0; i < (int)(30); i++) {
    bits[i] = val & 1;
    val >>= 1;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      cin >> brr[i][j];
    }
  }
  if (n == 1) {
    puts("0");
  } else {
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(n); j++) {
        if (i == j) continue;
        int val = brr[i][j];
        turnto(val);
        for (int k = 0; k < (int)(30); k++) {
          mat[k][i][j] = bits[k];
        }
      }
    }
    memset(arr, 0, sizeof(arr));
    for (int k = 0; k < (int)(30); k++) {
      for (int i = 0; i < (int)(n); i++) {
        for (int j = 0; j < (int)(n); j++) {
          if (i == j || !mat[k][i][j]) continue;
          arr[k][i] = 1;
          arr[k][j] = 1;
        }
      }
    }
    for (int i = 0; i < (int)(n); i++) {
      int res = 0;
      for (int k = (int)(29); k >= (int)(0); k--) {
        res <<= 1;
        res |= arr[k][i];
      }
      cout << res << ' ';
    }
    cout << endl;
  }
  return 0;
}
