#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double pi = 3.1415926535897932384626433832795;
const long double eps = 1e-9;
const int N = (int)1e5 + 5;
const int INF = (int)1e9 + 10;
char a[101][40];
int n, b[101][101];
long long get(int ind) {
  long long curst = 1;
  long long ans = 0;
  for (int i = 0; i < 40; i++) {
    ans = ans + curst * (int)(a[ind][i] - '0');
    curst *= 2;
  }
  return ans;
}
void go(int val, int x, int y) {
  string second = "";
  while (val != 0) {
    second += tostr(val % 2);
    val /= 2;
  }
  for (int i = 0; i < second.size(); i++)
    if (second[i] == '1') {
      a[x][i] = '1';
      a[y][i] = '1';
    }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.flags(ios::fixed);
  cout.precision(2);
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 40; j++) a[i][j] = '0';
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> b[i][j];
      if (i == j) continue;
      go(b[i][j], i, j);
    }
  for (int i = 0; i < n; i++) cout << get(i) << ' ';
  return 0;
}
