#include <bits/stdc++.h>
using namespace std;
long long a[103];
long long bb[103][103];
int main() {
  int test;
  while (scanf("%d", &test) != EOF) {
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= test; i++) {
      for (int j = 1; j <= test; j++) cin >> bb[i][j];
    }
    for (int i = 1; i <= test; i++) {
      for (int j = i + 1; j <= test; j++) {
        a[i] |= bb[i][j];
        a[j] |= bb[i][j];
      }
    }
    for (int i = 1; i <= test; i++) cout << a[i] << " ";
    cout << endl;
  }
}
