#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int a;
      cin >> a;
      if (i == j) continue;
      for (int k = 0; k < 30; k++) {
        if (a & (1 << k)) {
          v[i] |= (1 << k);
          v[j] |= (1 << k);
        }
      }
    }
  }
  for (int x : v) cout << x << " ";
  cout << endl;
}
