#include <bits/stdc++.h>
using namespace std;
int f[105][105];
int a[105];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      int x;
      cin >> x;
      if (i != j) a[i] |= x, a[j] |= x;
    }
  for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
  cout << endl;
  return 0;
}
