// {{{ Templates #include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz:" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = (ll)1e9 + 7LL; template constexpr T INF = numeric_limits::max() / 100; // }}} struct Graph { Graph(const ll n) { edge.resize(n, vector(n)); } void addEdge(const ll from, const ll to, const ll cost) { edge[from][to] = cost; edge[to][from] = cost; } vector> edge; }; inline ll common(const string& s1, const string& s2) { ll c = 0; for (ll i = 0; i < min(s1.size(), s2.size()); i++) { if (s1[i] == s2[i]) { c++; } else { break; } } return c + 1; } ll frac(const ll n) { ll ans = 1; for (ll i = 1; i <= n; i++) { ans = (ans * i) % MOD; } return ans; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; const ll maximum = 1 << N; vector S(N); Graph g(N); for (ll i = 0; i < N; i++) { cin >> S[i]; } for (ll i = 0; i < N; i++) { for (ll j = i + 1; j < N; j++) { g.addEdge(i, j, common(S[i], S[j])); } } vector costs(N); for (ll i = 1; i < maximum; i++) { vector used(N, false); ll num = i; ll cost = 0; ll pop = 0; for (ll d = 0; d < N; d++) { if (num % 2 == 1) { pop++; ll maxi = 1; for (ll j = 0; j < N; j++) { if (not used[j]) { maxi = max(maxi, g.edge[d][j]); } } cost = (cost + maxi) % MOD; used[d] = true; } num /= 2; } costs[pop - 1] = (costs[pop - 1] + cost) % MOD; } for (int i = 0; i < N; i++) { cout << (frac(i + 1) * costs[i]) % MOD << endl; } return 0; }