#include <bits/stdc++.h>
using namespace std;
int n, e[14][14], bic[1 << 14], rev[1 << 14];
int p[14], f[1 << 14][1 << 6][14];
long long ans[1 << 14];
vector<int> g[14][2];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      char ch;
      cin >> ch;
      if (ch == '1') {
        e[i][j] = 1;
        g[i][1].push_back(j);
      } else
        g[i][0].push_back(j);
    }
  bic[0] = 0;
  for (int i = 1; i < (1 << n); i++) bic[i] = bic[i >> 1] + (i & 1);
  rev[0] = 0;
  for (int i = 1; i < (1 << (n - 1)); i++)
    rev[i] = rev[i >> 1] >> 1 | (i & 1) << (n - 2);
  int b1 = n >> 1, b2 = n - b1;
  for (int s = 0; s < (1 << n); s++) {
    if (bic[s] == b1 || bic[s] == b2) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (s >> i & 1) p[cnt++] = i;
      }
      while (1) {
        int t = 0;
        for (int i = 0; i < cnt - 1; i++) {
          if (e[p[i]][p[i + 1]]) t |= 1 << i;
        }
        ++f[s][t][p[cnt - 1]];
        if (!next_permutation(p, p + cnt)) break;
      }
    }
  }
  int u = (1 << n) - 1, u1 = (1 << (b1 - 1)) - 1, u2 = (1 << (b2 - 1)) - 1;
  for (int s = 0; s < (1 << n); s++) {
    if (bic[s] == b1) {
      for (int t = 0; t < (1 << (n - 1)); t++)
        if (t <= rev[t]) {
          int t1 = t & u1, t2 = rev[t] & u2;
          int tmp = (t >> (b1 - 1)) & 1;
          int s1 = u ^ s;
          for (int i = 0; i < n; i++)
            if (f[s][t1][i]) {
              for (int j = 0; j < g[i][tmp].size(); j++) {
                ans[t] += f[s][t1][i] * f[s1][t2][g[i][tmp][j]];
              }
            }
        }
    }
  }
  for (int t = 0; t < (1 << (n - 1)); t++)
    if (t <= rev[t]) {
      printf("%lld ", ans[t]);
    } else
      printf("%lld ", ans[rev[t]]);
  printf("\n");
  return 0;
}
