#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 5;
const int maxbit = 30;
int n, x[maxn][maxn], sol[maxn], andAll;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &x[i][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j)
        for (int k = 0; k < maxbit; k++)
          if (x[i][j] & (1 << k) && !(sol[i] & (1 << k))) sol[i] += (1 << k);
  for (int i = 0; i < n; i++) printf("%d ", sol[i]);
  return 0;
}
