#include <bits/stdc++.h>
using namespace std;
int main() {
  int mas[105][105] = {0};
  int n;
  scanf("%d ", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d ", &mas[i][j]);
    }
  }
  int res[105] = {0};
  for (int i = 0; i < n; i++) {
    int buf = 0;
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      buf |= mas[i][j];
    }
    res[i] = buf;
  }
  for (int i = 0; i < n; i++) printf("%d ", res[i]);
  printf("\n");
  return 0;
}
