N, *S = open(0).read().split()

S = [str(sorted(s)) for s in S]

D = {}

ans = 0

for s in S:

    if s in D:

        ans += D[s]

        D[s] += 1

    else:

        D[s] = 1

print(ans)
from collections import Counter



N, *S = open(0).read().split()

S = [''.join(sorted(s)) for s in S]

C = Counter(S)



ans = 0

for k, v in list(C.items()):

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

print(ans)

N, *S = open(0).read().split()
S = [str(sorted(s)) for s in S]
D = {}
ans = 0
for s in S:
    if s in D:
        ans += D[s]
        D[s] += 1
    else:
        D[s] = 1
print(ans)

from collections import Counter

N, *S = open(0).read().split()
S = ["".join(sorted(s)) for s in S]
C = Counter(S)
ans = 0
for k, v in list(C.items()):
    ans += v * (v - 1) // 2
print(ans)

+from collections import Counter + -S = [str(sorted(s)) for s in S] -D = {} +S = ["".join(sorted(s)) for s in S] +C = Counter(S) -for s in S: -    if s in D: -        ans += D[s] -        D[s] += 1 -    else: -        D[s] = 1 +for k, v in list(C.items()): +    ans += v * (v - 1) // 2