import collections

n=int(eval(input()))

s=[str(sorted(eval(input())))for i in range(n)]

c=collections.Counter(s)

l=sum((i*(i-1)/2)for i in list(c.values()))

print((int(l)))
import collections

n=int(eval(input()))

print((int(sum((i*(i-1)/2)for i in list(collections.Counter([str(sorted(eval(input())))for i in range(n)]).values())))))
import collections

n = int(eval(input()))
s = [str(sorted(eval(input()))) for i in range(n)]
c = collections.Counter(s)
l = sum((i * (i - 1) / 2) for i in list(c.values()))
print((int(l)))

import collections

n = int(eval(input()))
print(
    (
        int(
            sum(
                (i * (i - 1) / 2)
                for i in list(
                    collections.Counter(
                        [str(sorted(eval(input()))) for i in range(n)]
                    ).values()
                )
            )
        )
    )
)

-s = [str(sorted(eval(input()))) for i in range(n)] -c = collections.Counter(s) -l = sum((i * (i - 1) / 2) for i in list(c.values())) -print((int(l))) +print( +    ( +        int( +            sum( +                (i * (i - 1) / 2) +                for i in list( +                    collections.Counter( +                        [str(sorted(eval(input()))) for i in range(n)] +                    ).values() +                ) +            ) +        ) +    ) +)