#include using namespace std; using ll = long long; const ll MOD = 1e9 + 7; ll cost[20][20], perm[21][21]; ll dp1[1 << 20][20], dp2[1 << 20][21]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { cost[i][j] = 1; for (int k = 0; k < min(s[i].length(), s[j].length()); k++) { if (s[i][k] != s[j][k]) break; cost[i][j]++; } cost[j][i] = cost[i][j]; } } for (int i = 0; i < n; i++) dp1[1 << i][i] = 1; for (int i = 0; i < (1 << n); i++) { for (int j = 0; j < n; j++) { if (i & (1 << j)) { for (int k = 0; k < n; k++) { if (i & (1 << k)) continue; dp1[i | (1 << k)][j] = max(dp1[i][j], cost[k][j]); } } } } for (int i = 0; i < n; i++) perm[i][0] = 1; for (int i = 1; i < n; i++) { for (int j = 1; j <= i; j++) { perm[i][j] = perm[i][j - 1] * (i - j + 1) % MOD; } } for (int i = 0; i < n; i++) { for (int j = 0; j < (1 << n) - 1; j++) { if (__builtin_popcount(j) < i) continue; for (int k = 0; k < n; k++) { if (j & (1 << k)) continue; (dp2[j | (1 << k)][i + 1] += dp2[j][i] + perm[__builtin_popcount(j)][i] * dp1[j | (1 << k)][k] % MOD) %= MOD; } } } for (int i = 1; i <= n; i++) { cout << dp2[(1 << n) - 1][i] << endl; } return 0; }