from collections import Counter



N = int(eval(input()))

A = [0]*N



for i in range(N):

    #各文字列に番号A[i]を与える

    string = eval(input())

    flag = True

    for j in range(10):

        A[i]+=10**(ord(string[j])-ord('a'))

        if(j<9):

            if(string[j]!=string[j+1]):

                flag = False

    if flag:

        A[i] = (ord(string[0])-ord('a')+1)*(-1)

    

C = Counter(A)

ans=0



for i in list(C.values()):

    if i==1:

        continue

    ans+=i*(i-1)//2



print(ans)
from collections import Counter



N = int(eval(input()))

A = []



for i in range(N):

    s = "".join(sorted(eval(input())))

    A.append(s)



C = Counter(A)

ans=0



for i in list(C.values()):

    if i==1:

        continue

    ans+=i*(i-1)//2



print(ans)

from collections import Counter

N = int(eval(input()))
A = [0] * N
for i in range(N):
    # 各文字列に番号A[i]を与える
    string = eval(input())
    flag = True
    for j in range(10):
        A[i] += 10 ** (ord(string[j]) - ord("a"))
        if j < 9:
            if string[j] != string[j + 1]:
                flag = False
    if flag:
        A[i] = (ord(string[0]) - ord("a") + 1) * (-1)
C = Counter(A)
ans = 0
for i in list(C.values()):
    if i == 1:
        continue
    ans += i * (i - 1) // 2
print(ans)

from collections import Counter

N = int(eval(input()))
A = []
for i in range(N):
    s = "".join(sorted(eval(input())))
    A.append(s)
C = Counter(A)
ans = 0
for i in list(C.values()):
    if i == 1:
        continue
    ans += i * (i - 1) // 2
print(ans)

-A = [0] * N +A = [] -    # 各文字列に番号A[i]を与える -    string = eval(input()) -    flag = True -    for j in range(10): -        A[i] += 10 ** (ord(string[j]) - ord("a")) -        if j < 9: -            if string[j] != string[j + 1]: -                flag = False -    if flag: -        A[i] = (ord(string[0]) - ord("a") + 1) * (-1) +    s = "".join(sorted(eval(input()))) +    A.append(s)