from collections import defaultdict import sys def main(): input = lambda: sys.stdin.readline()[:-1] N = int(input()) S = sys.stdin.read().splitlines() name = defaultdict(set) for i, si in enumerate(S): for j in range(len(si)): s = si[:j] + "_" + si[j + 1 :] name[s].add(i) ans = [] for si in S: a = set() for i in range(len(si)): s = si[:i] + "_" + si[i + 1 :] a |= name[s] ans.append(len(a) - 1) print(*ans, sep="\n") if not __debug__: f = open(sys.argv[1], "r") sys.stdin = f main()