#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define FOR(i, n, m) for(int i = (m); i < (int)(n); i++) using ll = long long; using ld = long double; inline bool f(const ll& a, const ll& b){ const ll c = a ^ b; constexpr ll mask = 0b011111; return !( ~(mask << (5ll * 0)) & c && ~(mask << (5ll * 1)) & c && ~(mask << (5ll * 2)) & c && ~(mask << (5ll * 3)) & c && ~(mask << (5ll * 4)) & c && ~(mask << (5ll * 5)) & c && ~(mask << (5ll * 6)) & c && ~(mask << (5ll * 7)) & c && ~(mask << (5ll * 8)) & c && ~(mask << (5ll * 9)) & c ); } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll N; cin >> N; vector S(N); vector> A(11); vector cnt(N, 0); REP(i, N){ string s; cin >> s; ll tmp = 0; for(auto c: s){ tmp <<= 5ll; tmp |= c - 'a'; } S[i] = tmp; A[s.size()].emplace_back(i); } REP(i, 11){ REP(j, A[i].size()){ const auto u = A[i][j]; FOR(k, A[i].size(), j+1){ const auto v = A[i][k]; bool t = f(S[u], S[v]); //cerr << S[u] << " " << S[v] << " " << t << endl; cnt[u] += t; cnt[v] += t; } } } REP(i, N){ cout << cnt[i] << endl; } }