from collections import Counter

n = int(eval(input()))

L = [''.join(sorted(eval(input()))) for i in range(n)]

c = Counter(L)

cnt = 0

for ele in list(c.values()):

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

print((int(cnt)))
from collections import Counter

import sys

n = int(sys.stdin.readline())

L = [''.join(sorted(sys.stdin.readline().strip())) for _ in range(n)]

ans = 0

L = Counter(L)

for num in list(L.values()):

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

print(ans)
from collections import Counter

n = int(eval(input()))
L = ["".join(sorted(eval(input()))) for i in range(n)]
c = Counter(L)
cnt = 0
for ele in list(c.values()):
    cnt += ele * (ele - 1) / 2
print((int(cnt)))

from collections import Counter
import sys

n = int(sys.stdin.readline())
L = ["".join(sorted(sys.stdin.readline().strip())) for _ in range(n)]
ans = 0
L = Counter(L)
for num in list(L.values()):
    ans += num * (num - 1) // 2
print(ans)

+import sys -n = int(eval(input())) -L = ["".join(sorted(eval(input()))) for i in range(n)] -c = Counter(L) -cnt = 0 -for ele in list(c.values()): -    cnt += ele * (ele - 1) / 2 -print((int(cnt))) +n = int(sys.stdin.readline()) +L = ["".join(sorted(sys.stdin.readline().strip())) for _ in range(n)] +ans = 0 +L = Counter(L) +for num in list(L.values()): +    ans += num * (num - 1) // 2 +print(ans)