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