#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 3;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int b[MAXN][MAXN];
int a[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> b[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++) {
      a[i] = a[i] | b[i][j];
      a[j] = a[j] | b[i][j];
    }
  for (int i = 0; i < n; i++) cout << a[i] << ' ';
  return 0;
}
