#include <bits/stdc++.h>
using namespace std;
long i, n, b[200][200], ma, j, t, ans, a[200];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      cin >> t;
      if (i != j) {
        a[i] |= t;
        a[j] |= t;
      }
    }
  cout << a[1];
  for (i = 2; i <= n; i++) cout << " " << a[i];
  cout << endl;
}
