#include <bits/stdc++.h>
using namespace std;
unsigned mx[112][112];
int main() {
  int n;
  cin >> n;
  ;
  for (int i = (0); i < n; i++)
    for (int j = (0); j < n; j++) cin >> mx[i][j];
  bool f = 1;
  for (int i = (0); i < n; i++) {
    unsigned val = 0;
    for (int j = (0); j < n; j++) {
      if (i != j) val |= mx[i][j];
    }
    if (f)
      f = 0;
    else
      cout << " ";
    cout << val;
  }
  cout << endl;
  return 0;
}
