#include <bits/stdc++.h>
using namespace std;
long long arr[200100], barr[200100];
long long M = 998244353;
multiset<long long> st;
int main() {
  long long t, n, i, j, k, l, m;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long p;
  t = 1;
  while (t--) {
    cin >> n;
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) {
        cin >> k;
        if (i != j) arr[i] = arr[i] | k;
      }
    for (i = 1; i <= n; i++) cout << arr[i] << ' ';
    cout << '\n';
  }
  return 0;
}
