def f(array):

    temp = 'abcdefghijklmnopqrstuvwxyz'

    res = [0] * len(temp)

    cnt = 0

    for x in array:

        res[temp.index(x)] += 1

        cnt += 1

        if cnt == 10:

            break

    return ''.join([str(i) for i in res])



N = int(eval(input()))

s = [''.join(f(eval(input()))) for i in range(N)]



dic = {}

for i in range(N):

    if s[i] in dic:

        dic[s[i]] += 1

    else:

        dic[s[i]] = 1



cnt = 0

for v in list(dic.values()):

    cnt += v * (v - 1) // 2



print(cnt)







N = int(eval(input()))

s = [''.join(sorted(eval(input()))) for i in range(N)]



dic = {}

cnt = 0

for i in range(N):

    if s[i] in dic:

        cnt += dic[s[i]]

        dic[s[i]] += 1

    else:

        dic[s[i]] = 1

print(cnt)







def f(array):
    temp = "abcdefghijklmnopqrstuvwxyz"
    res = [0] * len(temp)
    cnt = 0
    for x in array:
        res[temp.index(x)] += 1
        cnt += 1
        if cnt == 10:
            break
    return "".join([str(i) for i in res])


N = int(eval(input()))
s = ["".join(f(eval(input()))) for i in range(N)]
dic = {}
for i in range(N):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
cnt = 0
for v in list(dic.values()):
    cnt += v * (v - 1) // 2
print(cnt)

N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for i in range(N)]
dic = {}
cnt = 0
for i in range(N):
    if s[i] in dic:
        cnt += dic[s[i]]
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
print(cnt)

-def f(array): -    temp = "abcdefghijklmnopqrstuvwxyz" -    res = [0] * len(temp) -    cnt = 0 -    for x in array: -        res[temp.index(x)] += 1 -        cnt += 1 -        if cnt == 10: -            break -    return "".join([str(i) for i in res]) - - -s = ["".join(f(eval(input()))) for i in range(N)] +s = ["".join(sorted(eval(input()))) for i in range(N)] +cnt = 0 +        cnt += dic[s[i]] -cnt = 0 -for v in list(dic.values()): -    cnt += v * (v - 1) // 2