#include <bits/stdc++.h>
using namespace std;
int i, j, k, m, n, l;
int a[100 + 10][100 + 10], b[100 + 10][100 + 10], c[100 + 10];
bool v[100 + 10];
int main() {
  while (cin >> n) {
    memset(c, 0, sizeof(c));
    for (int i = (1); i <= (n); ++i)
      for (int j = (1); j <= (n); ++j) scanf("%d", &a[i][j]);
    for (int k = 0; k < (31); ++k) {
      for (int i = (1); i <= (n); ++i)
        for (int j = (1); j <= (n); ++j)
          if (i != j) {
            b[i][j] = a[i][j] & (1 << k);
            if (b[i][j]) c[i] |= (1 << k), c[j] |= (1 << k);
          }
    }
    for (int i = (1); i <= (n); ++i) {
      if (i - 1) putchar(' ');
      printf("%d", c[i]);
    }
    putchar('\n');
  }
  return 0;
}
