N = int(input()) dict = {} dict2 = {} for i in range(N): tmp = list(input()) for j in range(len(tmp)): if j == 0: tmp2 = "".join(tmp[1:]) + str(j) elif j == len(tmp)-1: tmp2 = "".join(tmp[:-1]) + str(j) else: tmp2 = "".join(tmp[:j]+tmp[j+1:]) + str(j) if tmp2 not in dict: dict[tmp2] = 1 dict2[tmp2] = [i] else: dict[tmp2] += 1 dict2[tmp2].append(i) ans = [0]*N for i,v in dict2.items(): if len(v)>=2: for j in v: ans[j]+=(len(v)-1) # print(i,v) #print(dict2) for i,v in enumerate(ans): print(v)