#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int n, b[105][105], a[105];
void solve() {
  memset(a, 0, sizeof(a));
  for (int k = 0; k <= 30; k++) {
    int t = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i != j) {
          a[i] |= (b[i][j] & (1 << k));
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << ' ';
  }
  cout << endl;
}
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> b[i][j];
      }
    }
    solve();
  }
}
