n=int(input()) ss=[] d={} for i in range(n): s=list(input()) for j in range(len(s)): t=s[j] for k in range(26): s[j]=chr(k+ord("a")) if tuple(s) not in d: d[tuple(s)]=0 s[j]=t d[tuple(s)]+=1 ss+=[s] for i in range(n): s=ss[i] c=0 for j in range(len(s)): t=s[j] for k in range(26): s[j]=chr(k+ord("a")) c+=d[tuple(s)]*(chr(k+ord("a"))!=t) s[j]=t print(c)