from collections import Counter

N = int(eval(input()))

S = ["".join(sorted(eval(input()))) for i in range(N)]

c = Counter(S)

print((sum(i*(i-1)//2 for i in list(c.values()))))
from collections import Counter

N = int(eval(input()))

C = Counter(["".join(sorted(eval(input()))) for n in range(N)])

print((sum(n*(n-1)//2 for n in list(C.values()))))
from collections import Counter

N = int(eval(input()))
S = ["".join(sorted(eval(input()))) for i in range(N)]
c = Counter(S)
print((sum(i * (i - 1) // 2 for i in list(c.values()))))

from collections import Counter

N = int(eval(input()))
C = Counter(["".join(sorted(eval(input()))) for n in range(N)])
print((sum(n * (n - 1) // 2 for n in list(C.values()))))

-S = ["".join(sorted(eval(input()))) for i in range(N)] -c = Counter(S) -print((sum(i * (i - 1) // 2 for i in list(c.values())))) +C = Counter(["".join(sorted(eval(input()))) for n in range(N)]) +print((sum(n * (n - 1) // 2 for n in list(C.values()))))