#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, x;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) a[i] = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      if (j > i) {
        cin >> x;
        a[i] = a[i] | x;
        a[j] = a[j] | x;
      } else
        cin >> x;
    }
  for (i = 0; i < n; i++) cout << a[i] << " ";
}
