#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n][n];
  int b[n], ans = 0;
  for (int i = 0; i < n; i++) {
    ans = 0;
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      if (a[i][j] != -1) ans = ans | a[i][j];
    }
    b[i] = ans;
  }
  for (int i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
  cout << "\n";
  return 0;
}
