#include <bits/stdc++.h>
int n, ans[110], a[110][110][33];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      int p;
      scanf("%d", &p);
      for (int k = 0; k <= 30; ++k) a[i][j][k] = p & (1 << k);
    }
  for (int k = 0; k <= 30; ++k) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if ((i != j) && (a[i][j][k])) ans[i] |= 1 << k, ans[j] |= 1 << k;
  }
  for (int i = 1; i < n; ++i) printf("%d ", ans[i]);
  printf("%d\n", ans[n]);
  return 0;
}
