#include using namespace std; using ll = long long; const ll MOD = 1e9 + 7; ll cost[20][20], fact[20]; ll dp[1 << 20], ans[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]; } } fact[0] = 1; for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;; for (int i = (1 << n) - 1; i >= 0; i--) { int cnt = n - __builtin_popcount(i); (ans[cnt] += dp[i]) %= MOD; ll tmp = 0; for (int j = 0; j < n; j++) { if (i & (1 << j)) { ll tmp = 1; for (int k = 0; k < n; k++) { if (i & (1 << k)) tmp = max(tmp, cost[k][j]); } (dp[i ^ (1 << j)] += dp[i] + fact[cnt] * tmp % MOD) %= MOD; } } } for (int i = 1; i <= n; i++) { cout << ans[i] << endl; } return 0; }