from collections import Counter

 

N = int(eval(input()))

 

ans = {}

answer = 0

for _ in range(N):

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

 

    if s not in ans:

        ans[s] = 0

 

    else:

        ans[s] += 1

        answer += ans[s]

 

print(answer)
N = int(eval(input()))

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

 

from collections import Counter

counter = Counter(s)

ans = sum(n*(n-1)//2 for n in list(counter.values()))

print(ans)
from collections import Counter

N = int(eval(input()))
ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(eval(input())))
    if s not in ans:
        ans[s] = 0
    else:
        ans[s] += 1
        answer += ans[s]
print(answer)

N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
from collections import Counter

counter = Counter(s)
ans = sum(n * (n - 1) // 2 for n in list(counter.values()))
print(ans)

+N = int(eval(input())) +s = ["".join(sorted(eval(input()))) for _ in range(N)] -N = int(eval(input())) -ans = {} -answer = 0 -for _ in range(N): -    s = "".join(sorted(eval(input()))) -    if s not in ans: -        ans[s] = 0 -    else: -        ans[s] += 1 -        answer += ans[s] -print(answer) +counter = Counter(s) +ans = sum(n * (n - 1) // 2 for n in list(counter.values())) +print(ans)