#include <bits/stdc++.h>
using namespace std;
int a[110][110], n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  for (int i = 0; i < n; i++) {
    int x = 0;
    for (int j = 0; j < n; j++)
      if (i != j) x |= a[i][j];
    cout << x << " ";
  }
}
