#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
int n, m, i, j, k, gr[18][18];
long long dp[1 << 18][18], f[19][1 << 18], g[19][1 << 18], ans[1 << 18];
vector<int> v;
void fwt(long long *a, int n) {
  int i, j;
  for (i = 1; i < n; i <<= 1)
    for (((j)) = (0); ((j)) <= (((int)(n)) - 1); ((j))++)
      if (i & j) {
        a[j] += a[j - i];
      }
}
void ifwt(long long *a, int n) {
  int i, j;
  for (i = 1; i < n; i <<= 1)
    for (((j)) = (0); ((j)) <= (((int)(n)) - 1); ((j))++)
      if (i & j) {
        a[j - i] -= a[j];
      }
}
void dfs(int d, int rem, int lim) {
  if (rem == 0) {
    long long res = 0;
    int i, j;
    for (((i)) = (0); ((i)) <= (((int)((1 << n))) - 1); ((i))++) {
      if ((n - __builtin_popcount(i)) & 1)
        res -= g[d][i];
      else
        res += g[d][i];
    }
    vector<int> tmp = v;
    do {
      int s = 0, t = 0;
      for (((i)) = (0); ((i)) <= (((int)(tmp.size())) - 1); ((i))++) {
        for (((j)) = (1); ((j)) <= ((tmp[i] - 1)); ((j))++) {
          s |= (1 << (t++));
        }
        t++;
      }
      ans[s] += res;
    } while (prev_permutation((tmp).begin(), (tmp).end()));
    return;
  }
  int i, j;
  for (((i)) = (1); ((i)) <= ((min(lim, rem))); ((i))++) {
    v.push_back(i);
    for (((j)) = (0); ((j)) <= (((int)((1 << n))) - 1); ((j))++) {
      g[d + 1][j] = g[d][j] * f[i][j];
    }
    dfs(d + 1, rem - i, i);
    v.pop_back();
  }
}
int main() {
  cin >> n;
  for (((i)) = (0); ((i)) <= (((int)(n)) - 1); ((i))++)
    for (((j)) = (0); ((j)) <= (((int)(n)) - 1); ((j))++) {
      char c;
      cin >> c;
      gr[i][j] = (c & 1);
    }
  for (((i)) = (0); ((i)) <= (((int)(n)) - 1); ((i))++) dp[1 << i][i] = 1;
  for (((i)) = (0); ((i)) <= (((int)((1 << n))) - 1); ((i))++)
    for (((j)) = (0); ((j)) <= (((int)(n)) - 1); ((j))++)
      if ((i >> j) & 1)
        for (((k)) = (0); ((k)) <= (((int)(n)) - 1); ((k))++)
          if (!((i >> k) & 1) && gr[j][k]) dp[i | (1 << k)][k] += dp[i][j];
  for (((i)) = (0); ((i)) <= (((int)((1 << n))) - 1); ((i))++) {
    long long s = 0;
    for (((j)) = (0); ((j)) <= (((int)(n)) - 1); ((j))++)
      if ((i >> j) & 1) s += dp[i][j];
    f[__builtin_popcount(i)][i] = s;
  }
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) fwt(f[i], (1 << n));
  for (((i)) = (0); ((i)) <= (((int)((1 << n))) - 1); ((i))++) g[0][i] = 1;
  dfs(0, n, n);
  ifwt(ans, (1 << (n - 1)));
  for (((i)) = (0); ((i)) <= (((int)((1 << (n - 1)))) - 1); ((i))++)
    printf("%lld ", ans[i]);
  return 0;
}
