#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x = 0, y;
    for (int j = 0; j < n; ++j) {
      scanf("%d", &y);
      if (i == j) continue;
      for (int k = 0; k < 30; ++k)
        if (y & (1 << k)) x |= (1 << k);
    }
    printf("%d ", x);
  }
  return 0;
}
