#include <bits/stdc++.h>
using namespace std;
int n;
char str[6000];
int pol1[6000];
int pol2[6000];
void p1() {
  for (int i = 0; str[i]; ++i) {
    for (int j = 0; i - j >= 0 && str[i + j]; ++j) {
      if (str[i - j] == str[i + j]) {
        ++pol1[i];
      } else {
        break;
      }
    }
  }
}
void p2() {
  for (int i = 0; str[i]; ++i) {
    for (int j = 0; i - j >= 0 && str[i + j + 1]; ++j) {
      if (str[i - j] == str[i + j + 1]) {
        ++pol2[i];
      } else {
        break;
      }
    }
  }
}
int fun1(int j, int a, int b) {
  return min(min(pol1[j], j - a + 1), b - j + 1);
}
int fun2(int j, int a, int b) { return min(min(pol2[j], j - a + 1), b - j); }
int arr[5001][5001];
void init() {
  for (int a = 0; str[a]; ++a) {
    for (int b = a; str[b]; ++b) {
      int sum = 0;
      for (int j = a; j <= b; ++j) {
        sum += fun1(j, a, b);
        sum += fun2(j, a, b);
      }
      arr[a][b] = sum;
    }
  }
}
int sx[2], sy[2];
void zadacha() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    sx[t - 1] += x;
    sy[t - 1] += y;
  }
  if (sx[0] >= sy[0]) {
    cout << "LIVE\n";
  } else {
    cout << "DEAD\n";
  }
  if (sx[1] >= sy[1]) {
    cout << "LIVE\n";
  } else {
    cout << "DEAD\n";
  }
}
void B() {
  cin >> str;
  int st = 3;
  if (str[0] == 'f') {
    cout << "ftp://";
    st = 3;
  } else {
    cout << "http://";
    st = 4;
  }
  int size = strlen(str);
  int i = size - 1;
  int en = 0;
  for (; i >= 0; --i) {
    if (str[i] == 'u' && str[i - 1] == 'r') {
      en = i - 1;
      break;
    }
  }
  for (int j = st; j < en; ++j) {
    cout << str[j];
  }
  cout << ".ru";
  en += 2;
  if (en != size) {
    cout << '/';
  }
  for (int j = en; j < size; ++j) {
    cout << str[j];
  }
}
void C() {
  cin >> str;
  int m_plus = 0;
  int m_minus = 0;
  int plus = 0;
  int minus = 0;
  for (int i = 0; str[i]; ++i) {
    if (str[i] == '+') {
      plus++;
      m_plus = max(m_plus, plus);
      if (minus > 0) --minus;
    } else {
      minus++;
      m_minus = max(m_minus, minus);
      if (plus > 0) --plus;
    }
  }
  cout << max(m_minus, m_plus);
}
int mas[101][101];
void D() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &mas[i][j]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    int rez = 0;
    for (int j = 1; j <= n; ++j) {
      if (i == j) continue;
      rez |= mas[i][j] | mas[j][i];
    }
    printf("%d ", rez);
  }
}
int main() {
  D();
  return 0;
  C();
  return 0;
  B();
  return 0;
  zadacha();
  return 0;
  scanf("%s", str);
  p1();
  p2();
  scanf("%d", &n);
  init();
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    printf("%d\n", arr[a][b]);
  }
  return 0;
}
