#include using namespace std; typedef long long ll; const ll MOD = ll(1e9 + 7); int N; ll com[20][20]; ll dp[1 << 20]; ll cnt[1 << 20]; string s[20]; ll ans[22]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; for(int i = 0; i < N; i++) { cin >> s[i]; } for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { if(i == j) continue; for(int k = 0; k < min(s[i].size(), s[j].size()); k++) { if(s[i][k] != s[j][k]) break; com[i][j]++; } } } cnt[0] = 1; for(int i = 0; i < 1 << N; i++) { int num = 0; for(int j = 0; j < N; j++) { if(i >> j & 1) num++; } for(int j = 0; j < N; j++) { if(i >> j & 1) continue; ll h = 1; for(int k = 0; k < N; k++) { if(i >> k & 1) continue; h = max(h, com[j][k] + 1); } dp[i | (1 << j)] += dp[i] + cnt[i] * h; dp[i | (1 << j)] % MOD; cnt[i | (1 << j)] += cnt[i]; cnt[i | (1 << j)] % MOD; ans[num + 1] += dp[i] + cnt[i] * h; ans[num + 1] %= MOD; } } for(int i = 1; i <= N; i++) { cout << ans[i] << endl; } }