from collections import Counter as C

n,*s=open(0)

print((int(sum([x*(x-1)//2 for x in list(C(tuple(sorted(C(i.strip()).most_common(),key=lambda x:x[0]))for i in s).values())]))))
from collections import Counter as C

n,*s=open(0)

print((sum(x*(x-1)//2 for x in list(C(tuple(sorted(i.strip()))for i in s).values()))))
from collections import Counter as C

n, *s = open(0)
print(
    (
        int(
            sum(
                [
                    x * (x - 1) // 2
                    for x in list(
                        C(
                            tuple(
                                sorted(C(i.strip()).most_common(), key=lambda x: x[0])
                            )
                            for i in s
                        ).values()
                    )
                ]
            )
        )
    )
)

from collections import Counter as C

n, *s = open(0)
print(
    (
        sum(
            x * (x - 1) // 2
            for x in list(C(tuple(sorted(i.strip())) for i in s).values())
        )
    )
)

-        int( -            sum( -                [ -                    x * (x - 1) // 2 -                    for x in list( -                        C( -                            tuple( -                                sorted(C(i.strip()).most_common(), key=lambda x: x[0]) -                            ) -                            for i in s -                        ).values() -                    ) -                ] -            ) +        sum( +            x * (x - 1) // 2 +            for x in list(C(tuple(sorted(i.strip())) for i in s).values())