#include #define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i) #define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i) #define foreach(i, n) for(auto &i:(n)) #define all(x) (x).begin(), (x).end() #define bit(x) (1ll << (x)) #define lambda(RES_TYPE, ...) (function)[&](__VA_ARGS__) -> RES_TYPE #define method(FUNC_NAME, RES_TYPE, ...) function FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__) using namespace std; using ll = long long; using pii = pair; using pll = pair; //const ll MOD = (ll)1e9+7; const ll MOD = 998244353; const int INF = (ll)1e9+7; const ll INFLL = (ll)1e18; template using vvector = vector>; template using vvvector = vector>>; template using priority_queuer = priority_queue, greater>; template bool chmax(t &a, u b){if(a bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;} #ifdef DEBUG #define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<>=1; } return res; } ll modinv(ll x){ return modpow(x, MOD-2); } bool was_output = false; void print(); template void print(const vector &); template void print(const pair &); template void print(const t&); template void print(const Head&, const Tail&...); template void println(const vector>&); template void println(const vector&); template void println(const t&); template void println(const Head&, const Tail&...); void println(); void newline(); void print(){ return; } template void print(const vector&x){ for(const t&i:x)print(i); } template void print(const pair&p){ print(p.first); print(p.second); } template void print(const t&x){ if(was_output)cout<<" "; cout< void print(const Head&head,const Tail&...tail){ print(head); print(tail...); } template void println(const vector>&x){ for(vector i:x)println(i); } template void println(const vector&x){ for(const t&i:x)print(i); println(); } template void println(const t&x){ print(x); println(); } void println(){ if(was_output){ cout << endl; was_output = false; } } template void println(const Head&head,const Tail&...tail){ print(head); println(tail...); } void newline(){ was_output = true; println(); } template istream& operator>>(istream&is, vector&x){ for(auto &i:x)is >> i; return is; } template istream& operator>>(istream&is, pair&x){ is >> x.first >> x.second; return is; } template ostream& operator<<(ostream&os, vector &v){ os << "{"; for(t &i:v){ os << i << ", "; } os << "}"; return os; } template t in(){ t res; cin >> res; return res; } template vector sorted(vector line,function comp=[](t a,t b){return a vector reversed(vector line){ reverse(line.begin(),line.end()); return line; } string reversed(string str){ reverse(str.begin(),str.end()); return str; } long long gcd(long long a,long long b){ while(b){ a %= b; swap(a,b); } return a; } long long lcm(long long a,long long b){ return a / gcd(a,b) * b; } class output_initializer{ public: output_initializer(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout << setprecision(20); } };output_initializer OUTPUT_INITIALIZER_INSTANCE = output_initializer(); } using namespace templates; vector func(){ int n = in(); map> s; vector names(n); vector res(n,0); map StoI; rep(i,n){ names[i] = in(); s[names[i].size()].emplace_back(names[i]); StoI[names[i]] = i; } foreach(i,s){ rep(j,i.first){ map> table; foreach(k,i.second){ table[k.substr(0,j) + k.substr(j+1)].emplace_back(k); } foreach(k,table){ foreach(l,k.second){ res[StoI[l]] += k.second.size()-1; } } } } return res; } int main(){ foreach(i,func())println(i); return 0; }