#include <bits/stdc++.h>
using namespace std;
int n;
int arr[20][20];
long long ans[1048576];
namespace t1 {
bool chk[20] = {0};
int tNum = 0;
void calcSmall(int x, int l) {
  if (l == n) {
    ans[tNum]++;
    return;
  }
  for (int y = 0; y < n; y++) {
    if (chk[y]) continue;
    tNum <<= 1, chk[y] = 1;
    if (arr[x][y]) tNum ^= 1;
    calcSmall(y, l + 1);
    tNum >>= 1, chk[y] = 0;
  }
}
}  // namespace t1
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%1d", &arr[i][j]);
    }
  }
  if (n <= 9) {
    for (int i = 0; i < n; i++) {
      t1::chk[i] = 1;
      t1::tNum = 0;
      t1::calcSmall(i, 1);
      t1::chk[i] = 0;
    }
    for (int i = 0; i < (1 << (n - 1)); i++) printf("%lld ", ans[i]);
    return 0;
  }
  vector<int> tVec(n, 0);
  for (int i = 0; i < 7; i++) tVec[n - 1 - i] = 1;
  do {
    vector<int> sel0, sel1;
    for (int i = 0; i < n; i++) {
      if (tVec[i])
        sel1.push_back(i);
      else
        sel0.push_back(i);
    }
    long long chk1[64][15] = {{0}};
    do {
      int num = 0;
      for (int i = 1; i < 7; i++) num <<= 1, num |= arr[sel1[i - 1]][sel1[i]];
      chk1[num][sel1[0]]++;
    } while (next_permutation(sel1.begin(), sel1.end()));
    long long chk0[128][15] = {{0}};
    do {
      int num = 0;
      for (int i = 1; i < (int)sel0.size(); i++)
        num <<= 1, num |= arr[sel0[i - 1]][sel0[i]];
      for (auto x : sel1) {
        chk0[num * 2 + arr[sel0.back()][x]][x]++;
      }
    } while (next_permutation(sel0.begin(), sel0.end()));
    for (int j = 0; j < 128; j++) {
      for (auto k : sel1) {
        if (!chk0[j][k]) continue;
        for (int i = 0; i < 64; i++) {
          ans[i + (j << 6)] += chk1[i][k] * chk0[j][k];
        }
      }
    }
  } while (next_permutation(tVec.begin(), tVec.end()));
  for (int i = 0; i < (1 << (n - 1)); i++) printf("%lld ", ans[i]);
  return 0;
}
