N = int(eval(input()))

S = [0] * N

from collections import Counter

counter = Counter()

for i in range(N):

    k = "".join(sorted(input().strip()))

    counter[k] += 1



# 4

answer = 0

for k, c in list(counter.items()):

    f = 1

    if c == 1:

        continue

    answer += (c * (c-1)) // 2

print(answer)



from collections import Counter



def main():

    N = int(eval(input()))

    counter = Counter()

    for i in range(N):

        k = "".join(sorted(input().strip()))

        counter[k] += 1

    answer = 0

    for k, c in list(counter.items()):

        answer += (c * (c-1)) // 2

    print(answer)



def main2():

    N = int(eval(input()))

    counter = Counter("".join(sorted(input().strip())) for i in range(N))

    print((sum((c * (c-1)) // 2 for c in list(counter.values()))))



def main3():

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





main3()

N = int(eval(input()))
S = [0] * N
from collections import Counter

counter = Counter()
for i in range(N):
    k = "".join(sorted(input().strip()))
    counter[k] += 1
# 4
answer = 0
for k, c in list(counter.items()):
    f = 1
    if c == 1:
        continue
    answer += (c * (c - 1)) // 2
print(answer)

from collections import Counter


def main():
    N = int(eval(input()))
    counter = Counter()
    for i in range(N):
        k = "".join(sorted(input().strip()))
        counter[k] += 1
    answer = 0
    for k, c in list(counter.items()):
        answer += (c * (c - 1)) // 2
    print(answer)


def main2():
    N = int(eval(input()))
    counter = Counter("".join(sorted(input().strip())) for i in range(N))
    print((sum((c * (c - 1)) // 2 for c in list(counter.values()))))


def main3():
    print(
        (
            sum(
                (c * (c - 1)) // 2
                for c in list(
                    Counter(
                        "".join(sorted(input().strip()))
                        for i in range(int(eval(input())))
                    ).values()
                )
            )
        )
    )


main3()

-N = int(eval(input())) -S = [0] * N -counter = Counter() -for i in range(N): -    k = "".join(sorted(input().strip())) -    counter[k] += 1 -# 4 -answer = 0 -for k, c in list(counter.items()): -    f = 1 -    if c == 1: -        continue -    answer += (c * (c - 1)) // 2 -print(answer) + +def main(): +    N = int(eval(input())) +    counter = Counter() +    for i in range(N): +        k = "".join(sorted(input().strip())) +        counter[k] += 1 +    answer = 0 +    for k, c in list(counter.items()): +        answer += (c * (c - 1)) // 2 +    print(answer) + + +def main2(): +    N = int(eval(input())) +    counter = Counter("".join(sorted(input().strip())) for i in range(N)) +    print((sum((c * (c - 1)) // 2 for c in list(counter.values())))) + + +def main3(): +    print( +        ( +            sum( +                (c * (c - 1)) // 2 +                for c in list( +                    Counter( +                        "".join(sorted(input().strip())) +                        for i in range(int(eval(input()))) +                    ).values() +                ) +            ) +        ) +    ) + + +main3()