#include <bits/stdc++.h>
using namespace std;
using LL = long long;
namespace _buff {
const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
  if (ib == ie) {
    ib = ibuf;
    ie = ibuf + fread(ibuf, 1, BUFF, stdin);
  }
  return ib == ie ? -1 : *ib++;
}
}  // namespace _buff
LL read() {
  using namespace _buff;
  LL ret = 0;
  bool pos = true;
  char c = getc();
  for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
    assert(~c);
  }
  if (c == '-') {
    pos = false;
    c = getc();
  }
  for (; c >= '0' && c <= '9'; c = getc()) {
    ret = (ret << 3) + (ret << 1) + (c ^ 48);
  }
  return pos ? ret : -ret;
}
size_t reads(int *s) {
  using namespace _buff;
  size_t ret = 0;
  char c = getc();
  for (; c != '0' && c != '1'; c = getc()) {
    assert(~c);
  }
  for (; c == '0' || c == '1'; c = getc()) {
    s[ret++] = c - '0';
  }
  return ret;
}
const size_t N = 18;
const size_t P = 290;
int n, adj[N][N];
void fwt(LL f[], int n, int flag) {
  n = 1 << n;
  for (int m = 1, l = 2; m < n; m <<= 1, l <<= 1) {
    LL *x = f, *y = f + m;
    for (int i = 0; i < n; i += l) {
      for (int j = 0; j < m; ++j, ++x, ++y) {
        *y += *x * flag;
      }
      x += m;
      y += m;
    }
  }
}
void fmt(LL f[], int n) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0, _ = 1 << n; j < _; ++j) {
      if (j >> i & 1) {
        f[j ^ (1 << i)] -= f[j];
      }
    }
  }
}
LL f[1 << N], g[N][1 << N], gg[P], dp[1 << N][N];
using State = multiset<int>;
map<State, int> mp;
void get_dp() {
  for (int i = 0; i < n; ++i) {
    dp[1 << i][i] = 1;
  }
  for (int i = 1, _ = 1 << n; i < _; ++i) {
    LL &sum = g[__builtin_popcount(i)][i];
    for (int j = 0; j < n; ++j) {
      if (~i >> j & 1) continue;
      sum += dp[i][j];
      for (int k = 0; k < n; ++k) {
        if (i >> k & 1) continue;
        if (adj[j][k]) dp[i | (1 << k)][k] += dp[i][j];
      }
    }
  }
  g[0][0] = 1;
  for (int i = 0; i <= n; ++i) {
    fwt(g[i], n, 1);
  }
}
LL tmp[N + 1][1 << N];
void dfs(State st, int lid, int lsz, int dep = 1) {
  int m = accumulate(begin(st), end(st), 0);
  if (m<n && * st.rbegin() + m> n) return;
  int id = mp.size();
  mp[st] = id;
  for (int i = 0, _ = 1 << n; i < _; ++i) {
    tmp[dep][i] = tmp[dep - 1][i] * g[lsz][i];
  }
  if (m == n) {
    fwt(tmp[dep], n, -1);
    gg[id] = tmp[dep][(1 << n) - 1];
  }
  for (int i = *st.rbegin(); i + m <= n; ++i) {
    State nst = st;
    nst.emplace(i);
    dfs(nst, id, i, dep + 1);
  }
}
void get_state() {
  copy(g[0], g[0] + (1 << n), tmp[0]);
  mp[State()] = 0;
  for (int i = 1; i <= n; ++i) {
    State st;
    st.emplace(i);
    dfs(st, 0, i);
  }
}
void get_f() {
  for (int i = 0, _ = 1 << (n - 1); i < _; ++i) {
    State st;
    int lst = 1;
    for (int j = 0; j < n; ++j) {
      if (i >> j & 1) {
        ++lst;
      } else {
        st.emplace(lst);
        lst = 1;
      }
    }
    f[i] = gg[mp[st]];
  }
}
int main() {
  n = read();
  for (int i = 0; i < n; ++i) {
    assert(n == reads(adj[i]));
  }
  get_dp();
  get_state();
  get_f();
  fmt(f, n - 1);
  for (int i = 0, _ = 1 << n >> 1; i < _; ++i) {
    printf("%lld ", f[i]);
  }
  return 0;
}
