import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 10**9 + 7 def cumprod(A, MOD=MOD): L = len(A) Lsq = int(L**.5 + 1) A = np.resize(A, Lsq**2).reshape(Lsq, Lsq) for n in range(1, Lsq): A[:, n] *= A[:, n - 1] A[:, n] %= MOD for n in range(1, Lsq): A[n] *= A[n - 1, -1] A[n] %= MOD return A.ravel()[:L] def make_fact(U, MOD=MOD): x = np.arange(U, dtype=np.int64) x[0] = 1 fact = cumprod(x, MOD) x = np.arange(U, 0, -1, dtype=np.int64) x[0] = pow(int(fact[-1]), MOD - 2, MOD) fact_inv = cumprod(x, MOD)[::-1] fact.flags.writeable = False fact_inv.flags.writeable = False return fact, fact_inv def compute_lcp(S, T): S = np.array(list(S)) T = np.array(list(T)) n = min(len(S), len(T)) return np.count_nonzero(np.minimum.accumulate(S[:n] == T[:n])) N = int(readline()) words = read().split() words.append(b'~') words.sort() LCP = np.array([compute_lcp(S, T) for S, T in zip(words, words[1:])]) fact, fact_inv = make_fact(10**4) # (とる枚数n, 近い方からk番目(0-based)) に対して、それが採用される回数を求めたい coef = np.zeros((N + 1, N), np.int64) for n in range(1, N + 1): x = fact[n] * fact_inv[1:n + 1] % MOD * fact_inv[:n][::-1] % MOD x *= fact[:n] x %= MOD x *= fact[N - n:N][::-1] * fact_inv[N - n] % MOD x[:-1] -= x[1:] coef[n, :n] = x % MOD sum_cost = np.zeros(N, np.int64) for i in range(N): L = LCP[:i][::-1] R = LCP[i:] x = np.concatenate([np.minimum.accumulate(L), np.minimum.accumulate(R)]) x.sort() sum_cost += x[::-1] + 1 x = coef * sum_cost % MOD x = x.sum(axis=1) % MOD print('\n'.join(x[1:].astype(str)))