n = int(input()) cnt = {} def f(S): lst = [ord(s) - 96 for s in S] tot = 0 for l in lst: tot *= 26 tot += l times = 1 for l in lst[::-1]: tot -= times * l for j in range(1, 27): if j == l: continue tot += times * j cnt[tot] = cnt.get(tot, 0) + 1 tot -= times * j tot += times * l times *= 26 return tot lst = [] for _ in range(n): S = input() lst.append(f(S)) for s in lst: print(cnt.get(s, 0))