from collections import defaultdict
n=int(input())
d=defaultdict(int)
Ss=[]
for i in range(n):
  s=list(input())
  m=len(s)
  for j in range(m):
    t=s.copy()
    t[j]='!'
    t=tuple(t)
    d[t]+=1
  Ss.append(s)

for s in Ss:
  m=len(s)
  ans=-m
  for j in range(m):
    t=s.copy()
    t[j]='!'
    t=tuple(t)
    ans+=d[t]
  print(ans)