#include <bits/stdc++.h>
using namespace std;
int input[128];
int mat[128][128];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> mat[i][j];
    }
  }
  int num = 0;
  for (int i = 0; i < n; i++) {
    num = 0;
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      num |= mat[i][j];
    }
    input[i] = num;
  }
  for (int i = 0; i < n; i++) {
    cout << input[i] << " ";
  }
  cout << endl;
  return 0;
}
