#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, k, g, mx, mn, res, c, x, y, z, w, p, q, r, l, s, t;
  cin >> n;
  long long int a[n];
  memset(a, 0, sizeof(a));
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      cin >> m;
      if (i != j) a[i] |= m;
    }
  }
  for (long long int x : a) cout << x << " ";
  return 0;
}
