#include <bits/stdc++.h>
int mtr[100][100];
int a[100];
int main(int argc, char *argv[]) {
  int n, t;
  scanf("%d", &n);
  int max = 0, min = 0;
  int cur = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &mtr[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      a[i] |= mtr[i][j];
    }
  }
  for (int i = 0; i < n; ++i) printf("%d ", a[i]);
  return 0;
}
