#include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
void ipgraph(long long n, long long m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
vector<long long> g[N];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  long long t, i, j, k, p, q, r, x, y, u, v, n, m;
  cin >> n;
  vector<long long> a(n, 0);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cin >> x;
      if (i != j) a[i] = a[i] | x;
    }
  }
  for (i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
void ipgraph(long long n, long long m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
}
void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
}
