#include <bits/stdc++.h>
using namespace std;
int n, data[105][105], ans[105];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &data[i][j]);
  for (int k = 0; k < 31; k++) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (i != j) {
          if (data[i][j] & (1 << k)) {
            ans[i] |= 1 << k;
            ans[j] |= 1 << k;
          }
        }
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  puts("");
}
