import string import collections N = int(input()) S = [] CA = collections.Counter() for _ in range(N): S.append(input()) alphabets = list(string.ascii_lowercase) for s in S: s = 'a'+s+'a' for i in range(1,len(s)-1): for a in alphabets: CA[s[:i]+a+s[i+1:]]+=1 for s in S: print(CA['a'+s+'a']-len(s))