#include <bits/stdc++.h>
using namespace std;
const int N = 18;
int n;
unsigned long long chain[1 << N];
int e[N][N], popcnt[1 << N];
unsigned long long dftchain[N][1 << N];
void DFT(unsigned long long f[1 << N]) {
  for (int i = 1; i < (1 << n); i <<= 1)
    for (int j = 0; j < (1 << n); j += i << 1)
      for (int k = 0; k < i; k++) f[i + j + k] += f[j + k];
}
void IDFT(unsigned long long f[1 << N]) {
  for (int i = 1; i < (1 << n); i <<= 1)
    for (int j = 0; j < (1 << n); j += i << 1)
      for (int k = 0; k < i; k++) f[i + j + k] -= f[j + k];
}
void solve1() {
  static unsigned long long f[1 << N][N];
  memset(f, 0, sizeof(f));
  for (int i = 0; i < n; i++) f[1 << i][i] = 1;
  for (int S = 1; S < (1 << n); S++) {
    for (int i = 0; i < n; i++)
      if (S >> i & 1) {
        for (int j = 0; j < n; j++)
          if (~S >> j & 1) {
            int T = S | 1 << j;
            if (e[i][j]) f[T][j] += f[S][i];
          }
      }
  }
  for (int S = 1; S < (1 << n); S++)
    for (int i = 0; i < n; i++) chain[S] += f[S][i];
  for (int S = 1; S < (1 << n); S++) popcnt[S] = popcnt[S >> 1] + (S & 1);
  for (int S = 1; S < (1 << n); S++) dftchain[popcnt[S] - 1][S] = chain[S];
  for (int i = 1; i < n; i++) DFT(dftchain[i]);
}
int cho[20];
map<unsigned long long, unsigned long long> mp;
unsigned long long fac[N + 1];
void mul(const unsigned long long a[1 << N], const unsigned long long b[1 << N],
         unsigned long long c[1 << N]) {
  for (int S = 0; S < (1 << n); S++) c[S] = a[S] * b[S];
}
unsigned long long g[10][1 << N];
void calc(int tn) {
  unsigned long long hsh = 0;
  for (int i = 1; i < tn; i++) hsh = hsh * 233 + cho[i];
  int s = 0;
  static unsigned long long f[1 << N];
  for (int S = 0; S < (1 << n); S++) f[S] = g[tn - 1][S];
  IDFT(f);
  for (int i = 1; i < tn; i++) s += cho[i] + 1;
  long long tans = 0;
  for (int S = 0; S < (1 << n); S++)
    if (popcnt[S] == s) tans += f[S];
  mp[hsh] = tans;
}
void dfs(int t, int lst, int s) {
  if (t != 1) calc(t);
  for (int i = lst; i <= n; i++) {
    if (s + i > n - 1) continue;
    cho[t] = i;
    mul(g[t - 1], dftchain[i], g[t]);
    dfs(t + 1, i, s + i + 1);
  }
}
void solve2() {
  for (int S = 0; S < (1 << n); S++) g[0][S] = 1;
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i;
  dfs(1, 1, 0);
}
unsigned long long ans[1 << N];
int C[N + 1][N + 1];
void solve3() {
  for (int i = 0; i <= n; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
  }
  int cho[20];
  for (int S = 0; S < (1 << (n - 1)); S++) {
    if (!S) {
      ans[S] = fac[n];
      continue;
    }
    int tn = 0;
    int res = n;
    for (int i = 0, j; i < n - 1; i = j + 1) {
      j = i;
      if (~S >> i & 1) continue;
      while (j + 1 < n - 1 && (S >> (j + 1) & 1)) ++j;
      cho[++tn] = j - i + 1;
      res -= cho[tn] + 1;
    }
    sort(cho + 1, cho + tn + 1);
    unsigned long long hsh = 0;
    for (int i = 1; i <= tn; i++) hsh = hsh * 233 + cho[i];
    ans[S] = mp[hsh];
    for (int i = 0, j; i < n - 1; i = j + 1) {
      j = i;
      if (S >> i & 1) continue;
      while (j + 1 < n && (~S >> (j + 1) & 1)) ++j;
      int len = j - i;
      if (i == 0 || j == n - 2) ++len;
      ans[S] *= C[res][len] * fac[len];
      res -= len;
    }
  }
  for (int i = 1; i < (1 << (n - 1)); i <<= 1)
    for (int j = 0; j < (1 << (n - 1)); j += i << 1)
      for (int k = 0; k < i; k++) ans[j + k] -= ans[i + j + k];
}
char st[100];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", st);
    for (int j = 0; j < n; j++) e[i][j] = st[j] - 48;
  }
  solve1();
  solve2();
  solve3();
  for (int S = 0; S < (1 << (n - 1)); S++) printf("%llu ", ans[S]);
}
