# 二重ループは不可能だがSの長さは小さい # よってSを1文字ずつハテナ変形した文字列を作って数える # 自身のダミーを数えないように注意 N = int(input()) from collections import defaultdict dic = defaultdict(int) S = [] for i in range(N): s = input() S.append(s) for j in range(len(s)): temp = s[:j] + '?' + s[j+1:] dic[temp] += 1 #print(temp, dic) for s in S: ans = 0 for j in range(len(s)): temp = s[:j] + '?' + s[j+1:] ans += dic[temp]-1 print(ans)