from collections import Counter

n = int(eval(input()))

b = []

for i in range(n):

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

    b.append(a)

c = list(Counter(b).values())

ans = 0

for j in c:

    ans += int((j-1)*j/2)

print(ans)
from collections import Counter

n = int(eval(input()))

s = list(Counter([''.join(sorted(eval(input()))) for _ in range(n)]).values())

print((sum([i*(i-1)//2 for i in s if i != 1])))
from collections import Counter

n = int(eval(input()))
b = []
for i in range(n):
    a = "".join(sorted(eval(input())))
    b.append(a)
c = list(Counter(b).values())
ans = 0
for j in c:
    ans += int((j - 1) * j / 2)
print(ans)

from collections import Counter

n = int(eval(input()))
s = list(Counter(["".join(sorted(eval(input()))) for _ in range(n)]).values())
print((sum([i * (i - 1) // 2 for i in s if i != 1])))

-b = [] -for i in range(n): -    a = "".join(sorted(eval(input()))) -    b.append(a) -c = list(Counter(b).values()) -ans = 0 -for j in c: -    ans += int((j - 1) * j / 2) -print(ans) +s = list(Counter(["".join(sorted(eval(input()))) for _ in range(n)]).values()) +print((sum([i * (i - 1) // 2 for i in s if i != 1])))