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