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