import collections



N = int(eval(input()))

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

c = collections.Counter(s)

ans = 0

for si in set(s):

    n = c[si]

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

print(ans)

from collections import Counter



N = int(eval(input()))

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

c = Counter(s)



ans = 0



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

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



print(ans)

import collections

N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for si in set(s):
    n = c[si]
    ans += n * (n - 1) // 2
print(ans)

from collections import Counter

N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
c = Counter(s)
ans = 0
for ci in list(c.values()):
    ans += ci * (ci - 1) // 2
print(ans)

-import collections +from collections import Counter -c = collections.Counter(s) +c = Counter(s) -for si in set(s): -    n = c[si] -    ans += n * (n - 1) // 2 +for ci in list(c.values()): +    ans += ci * (ci - 1) // 2