Problem: This is the easy version of the problem. The difference is constraints on the number of wise men and the time limit. You can make hacks only if all versions of this task are solved.

n wise men live in a beautiful city. Some of them know each other.

For each of the n! possible permutations p_1, p_2, …, p_n of the wise men, let's generate a binary string of length n-1: for each 1 ≤ i < n set s_i=1 if p_i and p_{i+1} know each other, and s_i=0 otherwise. 

For all possible 2^{n-1} binary strings, find the number of permutations that produce this binary string.

Input

The first line of input contains one integer n (2 ≤ n ≤ 14) — the number of wise men in the city.

The next n lines contain a binary string of length n each, such that the j-th character of the i-th string is equal to '1' if wise man i knows wise man j, and equals '0' otherwise.

It is guaranteed that if the i-th man knows the j-th man, then the j-th man knows i-th man and no man knows himself.

Output

Print 2^{n-1} space-separated integers. For each 0 ≤ x < 2^{n-1}:

  * Let's consider a string s of length n-1, such that s_i = ⌊ \frac{x}{2^{i-1}} ⌋ mod 2 for all 1 ≤ i ≤ n - 1. 
  * The (x+1)-th number should be equal to the required answer for s. 

Examples

Input


3
011
101
110


Output


0 0 0 6 


Input


4
0101
1000
0001
1010


Output


2 2 6 2 2 6 2 2 

Note

In the first test, each wise man knows each other, so every permutation will produce the string 11.

In the second test:

  * If p = \{1, 2, 3, 4\}, the produced string is 101, because wise men 1 and 2 know each other, 2 and 3 don't know each other, and 3 and 4 know each other; 
  * If p = \{4, 1, 2, 3\}, the produced string is 110, because wise men 1 and 4 know each other, 1 and 2 know each other and 2, and 3 don't know each other; 
  * If p = \{1, 3, 2, 4\}, the produced string is 000, because wise men 1 and 3 don't know each other, 3 and 2 don't know each other, and 2 and 4 don't know each other. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 18;
vector<int> Q[400];
map<vector<int>, int> Map;
int tot, n, bit[1 << 18 | 2], q[20];
char e[20][20];
long long f[1 << (N - 1) | 2], jdb[400], dp[20][20], sum[20];
void dfs(int rest, int dq, vector<int> v) {
  if (!rest) {
    Q[++tot] = v;
    Map[v] = tot;
    return;
  }
  for (int i = (int)(dq); i <= (int)(rest); i++) {
    v.push_back(i);
    dfs(rest - i, i, v);
    v.pop_back();
  }
}
int main() {
  n = read();
  for (int i = (int)(0); i <= (int)(n - 1); i++) {
    scanf("%s", e[i]);
    for (int j = (int)(0); j <= (int)(n - 1); j++) e[i][j] -= '0';
  }
  vector<int> v;
  dfs(n, 1, v);
  memset((jdb), 0, sizeof(jdb));
  for (int i = (int)(0); i <= (int)((1 << n) - 1); i++) {
    bit[i] = bit[i >> 1] + (i & 1);
    memset((dp), 0, sizeof(dp));
    memset((sum), 0, sizeof(sum));
    int tt = 0;
    for (int j = (int)(0); j <= (int)(n - 1); j++)
      if (i >> j & 1) q[tt++] = j;
    for (int j = (int)(0); j <= (int)(tt - 1); j++) dp[0][j] = 1;
    for (int j = (int)(0); j <= (int)(n - 1); j++)
      for (int k = (int)(0); k <= (int)(tt - 1); k++)
        for (int l = (int)(0); l <= (int)(tt - 1); l++)
          if (e[q[k]][q[l]]) dp[j + 1][l] = dp[j + 1][l] + dp[j][k];
    for (int i = (int)(0); i <= (int)(n - 1); i++)
      for (int j = (int)(0); j <= (int)(tt - 1); j++) sum[i] += dp[i][j];
    for (int j = (int)(1); j <= (int)(tot); j++) {
      long long ans = 1;
      for (auto k : Q[j]) ans *= sum[k - 1];
      if ((n - bit[i]) & 1) ans = -ans;
      jdb[j] += ans;
    }
  }
  for (int i = (int)(0); i <= (int)((1 << (n - 1)) - 1); i++) {
    int dq = 1;
    vector<int> vv;
    for (int j = (int)(0); j <= (int)(n - 1); j++)
      if (i >> j & 1) {
        dq++;
      } else {
        vv.push_back(dq);
        dq = 1;
      }
    sort(vv.begin(), vv.end());
    f[i] = jdb[Map[vv]];
  }
  for (int i = (int)(0); i <= (int)(n - 2); i++)
    for (int j = (int)(0); j <= (int)((1 << (n - 1)) - 1); j++)
      if (j >> i & 1) f[j - (1 << i)] -= f[j];
  for (int i = (int)(0); i <= (int)((1 << (n - 1)) - 1); i++) wri(f[i]);
}