from collections import defaultdict n = int(input()) s = [input() for i in range(n)] ans = [0] * n for i in range(10): d = defaultdict(int) for j in range(n): if len(s[j]) > i: d[s[j][:i] + s[j][i + 1:]] += 1 for j in range(n): if len(s[j]) > i: ans[j] += d[s[j][:i] + s[j][i + 1:]] - 1 for i in range(n): print(ans[i])