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