#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector VI; typedef vector VL; typedef pair PI; const ll mod = 1e9 + 7; int main(void) { int n; cin >> n; vector s(n); REP(i, 0, n) { cin >> s[i]; s[i] += '$'; } vector dp(1 << n); dp[0] = 0; REP(bits, 1, 1 << n) { int k = __builtin_popcount(bits) - 1; ll fact = 1; REP(i, 0, k) { fact = fact * (i + 1) % mod; } ll tot = 0; vector remaining; REP(i, 0, n) { if ((bits & 1 << i) == 0) { remaining.push_back(s[i]); } } REP(i, 0, n) { if ((bits & 1 << i) == 0) { continue; } int idx = 1; while (true) { bool ok = true; REP(j, 0, remaining.size()) { if ((int) remaining[j].length() >= idx && remaining[j].substr(0, idx) == s[i].substr(0, idx)) { ok = false; break; } } if (not ok) { idx += 1; } else { break; } } tot += dp[bits ^ 1 << i] + idx * fact % mod; } dp[bits] = tot % mod; } VL tbl(n + 1, 0); REP(bits, 0, 1 << n) { tbl[__builtin_popcount(bits)] += dp[bits]; } REP(i, 1, n + 1) { cout << tbl[i] % mod << endl; } }