N = int(input())

strings = sorted(str(sorted(input())) for _ in range(N))



ans = 0

cnt = 1

for i in range(N - 1):

    if strings[i] == strings[i + 1]:

        cnt += 1

    else:

        if cnt > 1:

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

        cnt = 1

print(ans) if cnt <= 1 else print(ans + cnt * (cnt - 1) // 2)

from collections import defaultdict





N = int(eval(input()))

dic = defaultdict(int)

ans = 0

for _ in range(N):

    elem = ''.join(sorted(eval(input())))

    ans += dic[elem]

    dic[elem] += 1

print(ans)

N = int(input())
strings = sorted(str(sorted(input())) for _ in range(N))
ans = 0
cnt = 1
for i in range(N - 1):
    if strings[i] == strings[i + 1]:
        cnt += 1
    else:
        if cnt > 1:
            ans += cnt * (cnt - 1) // 2
        cnt = 1
print(ans) if cnt <= 1 else print(ans + cnt * (cnt - 1) // 2)

from collections import defaultdict

N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
    elem = "".join(sorted(eval(input())))
    ans += dic[elem]
    dic[elem] += 1
print(ans)

-N = int(input()) -strings = sorted(str(sorted(input())) for _ in range(N)) +from collections import defaultdict + +N = int(eval(input())) +dic = defaultdict(int) -cnt = 1 -for i in range(N - 1): -    if strings[i] == strings[i + 1]: -        cnt += 1 -    else: -        if cnt > 1: -            ans += cnt * (cnt - 1) // 2 -        cnt = 1 -print(ans) if cnt <= 1 else print(ans + cnt * (cnt - 1) // 2) +for _ in range(N): +    elem = "".join(sorted(eval(input()))) +    ans += dic[elem] +    dic[elem] += 1 +print(ans)