#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
long long ncr(long long n, long long r) {
  long long res = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
vector<long long> factors(long long n) {
  vector<long long> f;
  for (long long x = 2; x * x <= n; x++) {
    while (n % x == 0) {
      f.push_back(x);
      n /= x;
    }
  }
  if (n > 1) f.push_back(n);
  return f;
}
struct cor {
  int x, y;
};
const int MaxN = 4e5 + 10;
const int MAXN = 120 * 1000;
int cD(long long n) { return floor(log10(n) + 1); }
long long front[MaxN] = {0}, back[MaxN] = {0};
long long last = 1000000000007;
long long y, x2, x3, sum = 0, sum2 = 0, i, j, g, t, mid;
long long d1 = 0, d2 = 0;
long long x, n, k, q, r, m;
long long l;
const int mod = 998244353;
string s;
long long power(long long x, long long y) {
  int res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
long long n1, n2, nc, pc, h, zc, l2, l3, l4;
const int No = 3e5 + 5;
pair<long long, long long> p[No];
long long an, bn, cn, dn;
long long a[101][101];
long long b[MaxN];
void pcheck(long long a) {
  for (long long i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) {
      b[i]++;
      if (a / i > sqrt(a)) b[a / i]++;
    }
  }
  b[a]++;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  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++) {
    m = 0;
    for (int j = (0); j < (n); j++) {
      if (i != j) b[i] = b[i] | a[i][j];
    }
  }
  for (int i = (0); i < (n); i++) cout << b[i] << " ";
  return 0;
}
