#include #include #include #include using namespace std; typedef long long lint; #define MIN(a,b) ((a)<(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b)) #define MOD ((lint)1000000007) template ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; } cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; } /* 6 abc abcedaa abcdefg abvdegf aaa abceg */ lint ipow(lint x, lint n) { lint i, ret = 1; for (i = 0; i& S, lint bits, lint N) { lint fatigue = 0; vector sub; for (int i = 0; bits != 0, i < N; i++) { if (bits % 2) sub.push_back(S[i]); bits /= 2; } if (sub.size() == 1) fatigue = 1; else { fatigue += common_seq(sub[0], sub[1]) + 1; for (lint i = 1; i < sub.size() - 1; i++) { fatigue += MAX(common_seq(sub[i - 1], sub[i]), common_seq(sub[i], sub[i + 1])) + 1; } if (sub.size() != 2) { fatigue += common_seq(sub[sub.size() - 2], sub[sub.size() - 1]) + 1; } } lint prob = Combination(N, sub.size()) * fatigue % MOD; return prob; } int main() { lint N, pw, E[21] = { 0 }; cin >> N; vector S(N); for (lint i = 0; i < N; i++) { cin >> S[i]; //S[i].push_back('0'); } sort(S.begin(), S.end()); //cout << S << endl; pw = ipow(2, N); for (int b = 0; b < pw; b++) { lint nb = 0; for (int i = 1; i <= (1 << 20); i <<= 1) { if (b & 1) nb++; } E[nb] += fatigue(S, b, N); E[nb] %= MOD; } for (int i = 0; i < N; i++) cout << E[i] << endl; return 0; }