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) if 0: print("a =", a) print("D =", D) for x in X: print(D[x] - len(x))