#include <bits/stdc++.h>
int b[110][110][35], a[110][35];
int map[110][110];
int main() {
  int n, i, j, len, temp, ans;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= n; ++j) {
      scanf("%d", &map[i][j]);
      if (i == j) continue;
      len = 0;
      temp = map[i][j];
      while (temp) {
        b[i][j][len++] = temp & 1;
        temp >>= 1;
      }
    }
  }
  if (n == 1) {
    printf("0\n");
  } else if (n == 2) {
    printf("%d %d\n", map[1][2], map[1][2]);
  } else {
    for (len = 0; len <= 30; ++len) {
      for (i = 1; i <= n; ++i) {
        for (j = i + 1; j <= n; ++j) {
          if (b[i][j][len]) {
            a[i][len] = a[j][len] = 1;
          }
        }
      }
    }
    for (i = 1; i <= n; ++i) {
      ans = 0;
      for (len = 30; len >= 0; --len) {
        ans = (ans << 1) + a[i][len];
      }
      printf("%d", ans);
      if (i < n)
        printf(" ");
      else
        printf("\n");
    }
  }
  return 0;
}
