#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const double PI = acos(-1);
const long long INFF = (long long)1e18;
const int INF = (int)1e9;
const int mod = (int)1e9 + 7;
const int MAX = (int)1e2 + 7;
int st[MAX][MAX];
int ans[MAX];
int main(void) {
  int n;
  scanf("%d", &n);
  ;
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (1); j < (n + 1); ++j) scanf("%d", st[i] + j);
  if (n == 1)
    puts("0");
  else if (n == 2)
    printf("%d %d\n", st[1][2], st[1][2]);
  else {
    for (int i = (1); i < (n + 1); ++i) {
      for (int j = (1); j < (n + 1); ++j)
        if (j != i) {
          for (int l = 0; l < (30); ++l) {
            if (st[i][j] & (1 << l)) {
              ans[i] |= (1 << l);
              ans[j] |= (1 << l);
            }
          }
        }
    }
    for (int i = (1); i < (n + 1); ++i) printf("%d ", ans[i]);
  }
  return 0;
}
