alp = "abcdefghijklmnopqrstuvwxyz" N = int(input()) X = [] D = {} for _ in range(N): a = input() l = len(a) for i in range(l): for s in alp: b = a[:i] + s + a[i+1:] if b in D: D[b] += 1 else: D[b] = 1 X.append(a) for x in X: print(D[x] - len(x))