#include using namespace std; typedef long long int64; const int mod = 1e9 + 7; inline int64 modPow(int64 x, int64 n) { if(n == 0) return (1); int64 ret = modPow(x, n / 2); (ret *= ret) %= mod; if(n & 1) (ret *= x) %= mod; return (ret); } inline int64 modInv(int64 a) { return (modPow(a, mod - 2)); } int N; string S[2000]; int dat[2000][2000]; int64 fact[2001], inv[2001]; int main() { fact[0] = 1; for(int i = 1; i < 2001; i++) { (fact[i] = fact[i - 1] * i) %= mod; } for(int i = 0; i < 2001; i++) inv[i] = modInv(fact[i]); cin >> N; for(int i = 0; i < N; i++) { cin >> S[i]; S[i] += "*"; } for(int i = 0; i < N; i++) { dat[i][i] = 1; for(int j = 0; j < N; j++) { if(i == j) continue; int diff = 0; while(S[i][diff] == S[j][diff]) ++diff; dat[i][j] = diff + 1; } } int dp[1 << 20] = {}; dp[0] = 0; vector< int > ans(N + 1, 0); for(int i = 0; i < (1 << N); i++) { vector< int > yuki(N, 1); for(int j = 0; j < N; j++) { if(!((i >> j) & 1)) { for(int k = 0; k < N; k++) { if(!((i >> k) & 1)) yuki[j] = max(yuki[j], dat[j][k]); } } } int sz = __builtin_popcount(i); for(int j = 0; j < N; j++) { if((i >> j) & 1) continue; // (dp[i | (1 << j)] += (dp[i] + 1LL * yuki[j] * fact[sz] % mod) % mod) %= mod; // (アが及ぼすアへの道のりは 残りbit数!) for(int k = sz + 1; k <= N; k++) { int rest = N - (sz + 1); // 現時点での残りbit (ans[k] += yuki[j] * fact[sz] % mod * fact[rest] % mod * inv[N - k] % mod) %= mod; } } } /* for(int i = 0; i < (1 << N); i++) { (ans[__builtin_popcount(i)] += dp[i]) %= mod; } */ for(int i = 1; i <= N; i++) { cout << ans[i] << endl; } }