#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const int MAX_N = 100 + 10;
int b[MAX_N][MAX_N];
int a[MAX_N], mark[MAX_N];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> b[i][j];
  for (int r = 0; (1 << r) <= 1000 * 1000 * 1000; r++) {
    for (int i = 0; i < n; i++) mark[i] = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (i != j)
          if (b[i][j] & (1 << r)) {
            mark[i] = 1;
            mark[j] = 1;
          }
    for (int i = 0; i < n; i++)
      if (mark[i]) a[i] += (1 << r);
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << endl;
  return 0;
}
