d = {}

c = 0

for i in open(0):

    i = str(sorted(i))

    t = d.get(i, 0)

    c += t

    d[i] = t + 1

print(c)
from collections import*

print((sum(i * (i - 1) // 2 for i in list(Counter("".join(sorted(eval(input()))) for _ in [0] * int(eval(input()))).values()))))
d = {}
c = 0
for i in open(0):
    i = str(sorted(i))
    t = d.get(i, 0)
    c += t
    d[i] = t + 1
print(c)

from collections import *

print(
    (
        sum(
            i * (i - 1) // 2
            for i in list(
                Counter(
                    "".join(sorted(eval(input()))) for _ in [0] * int(eval(input()))
                ).values()
            )
        )
    )
)

-d = {} -c = 0 -for i in open(0): -    i = str(sorted(i)) -    t = d.get(i, 0) -    c += t -    d[i] = t + 1 -print(c) +from collections import * + +print( +    ( +        sum( +            i * (i - 1) // 2 +            for i in list( +                Counter( +                    "".join(sorted(eval(input()))) for _ in [0] * int(eval(input())) +                ).values() +            ) +        ) +    ) +)