#include <bits/stdc++.h>
using namespace std;
const int RLEN = 1 << 20 | 1;
inline char gc() {
  static char ibuf[RLEN], *ib, *ob;
  (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
  return (ib == ob) ? EOF : *ib++;
}
inline int read() {
  char ch = gc();
  int res = 0;
  bool f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) res = (res + (res << 2) << 1) + (ch ^ 48), ch = gc();
  return f ? res : -res;
}
inline long long readll() {
  char ch = gc();
  long long res = 0;
  bool f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) res = (res + (res << 2) << 1) + (ch ^ 48), ch = gc();
  return f ? res : -res;
}
inline int readstring(char *s) {
  int top = 0;
  char ch = gc();
  while (isspace(ch)) ch = gc();
  while (!isspace(ch) && ch != EOF) s[++top] = ch, ch = gc();
  return top;
}
template <typename tp>
inline void chemx(tp &a, tp b) {
  a < b ? a = b : 0;
}
template <typename tp>
inline void chemn(tp &a, tp b) {
  a > b ? a = b : 0;
}
const int N = 19, M = (1 << N) + 3;
int n, m, cnt[M];
long long val[M], ans[M], f[N][M], dp[M][N], s[M];
vector<int> e[N];
char str[N];
vector<int> now;
map<vector<int>, vector<int>> sta;
inline void calc() {
  long long res = 0;
  for (int i = 0; i < m; i++)
    if (cnt[i ^ (m - 1)] & 1)
      res -= val[i];
    else
      res += val[i];
  for (int &s : sta[now]) ans[s] += res;
}
void dfs(int s, int mx) {
  if (s > n) return;
  if (s == n) return calc();
  vector<long long> pre(m);
  for (int i = 0; i < m; i++) pre[i] = val[i];
  for (int i = mx; i + s <= n; i++) {
    if (s + i != n && s + i + i > n) continue;
    now.push_back(i);
    for (int j = 0; j < m; j++) val[j] *= f[i][j];
    dfs(s + i, i);
    for (int j = 0; j < m; j++) val[j] = pre[j];
    now.pop_back();
  }
}
inline void fmt(long long *f, int lim) {
  for (int mid = 1; mid < lim; mid <<= 1)
    for (int i = 0; i < lim; i += mid << 1)
      for (int j = 0; j < mid; j++) f[i + j + mid] += f[i + j];
}
int main() {
  n = read(), m = 1 << n;
  for (int i = 1; i < m; i++) cnt[i] = cnt[i >> 1] + (i & 1);
  for (int i = 0; i < n; i++) {
    readstring(str);
    for (int j = 1; j <= n; j++)
      if (str[j] == '1') {
        e[i].push_back(j - 1);
      }
  }
  for (int i = 0; i < n; i++) dp[1 << i][i] = 1;
  for (int i = 1; i < m; i++) {
    long long res = 0;
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) {
        long long now = dp[i][j];
        for (int &k : e[j])
          if (!(i & (1 << k))) {
            dp[i + (1 << k)][k] += now;
          }
        res += dp[i][j];
      }
    f[cnt[i]][i] = res;
  }
  for (int i = 1; i <= n; i++) fmt(f[i], m);
  for (int i = 0; i < m / 2; i++) {
    vector<int> pt;
    int p = 0;
    while (p < n) {
      int len = 1;
      while (i & (1 << p)) {
        len++, p++;
      }
      pt.push_back(len), p++;
    }
    sort(pt.begin(), pt.end());
    sta[pt].push_back(i);
  }
  for (int i = 0; i < m; i++) val[i] = 1;
  dfs(0, 1);
  for (int mid = 1; mid < m; mid <<= 1)
    for (int i = 0; i < m / 2; i += mid << 1)
      for (int j = 0; j < mid; j++) ans[i + j] -= ans[i + j + mid];
  for (int i = 0; i < m / 2; i++) cout << ans[i] << " ";
  return 0;
}
