#include <bits/stdc++.h>
using namespace std;
const int N = 109;
int A[N][N], a[N];
char str[509];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int aij;
      cin >> aij;
      if (i == j) continue;
      a[i] |= aij;
    }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
}
