#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() templateostream& operator<<(ostream& os,const pair&a){return os<<"("<void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<bool chmin(T&a,const T&b){return a>b?(a=b,1):0;} templatebool chmax(T&a,const T&b){return a> N; fact[0] = 1; for (int i = 1; i <= N; i++) fact[i] = (fact[i-1] * i) % MOD; REP(i, N) { cin >> s[i]; s[i] += "$"; } REP(i, N) REP(j, N) { int d = 0; if (i == j) d = 1; else { while (s[i][d] == s[j][d]) d++; d++; } diff[i][j] = d; } memset(dp, 0, sizeof(dp)); for (int s = 0; s < (1 << N); s++) { int on = __builtin_popcount(s); REP(k, N) if ((s >> k & 1) == 0) { int cost = 0; REP(j, N) if ((s >> j & 1) == 0) { chmax(cost, diff[k][j]); } // if (N == 3) { // cout << bitset<3>(s) << " " << dp[s] << " k=" << k << " " << cost << endl; // } (dp[s | (1 << k)] += dp[s] + cost * fact[on]) %= MOD; } } vector ans(N+1); for (int s = 0; s < (1 << N); s++) { (ans[__builtin_popcount(s)] += dp[s]) %= MOD; } for (int i = 1; i <= N; i++) { cout << ans[i] << endl; } return 0; } int main() { for (;!cin.eof();cin>>ws) main2(); return 0; }