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