N=int(eval(input()))

dictionary={}

count=0

for i in range(N):

    s=str(sorted(eval(input())))

    if s in dictionary:

        dictionary[s]+=1

        count+=dictionary[s]

    else:

        dictionary[s]=0

print(count)
import collections

N=int(eval(input()))

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

c=collections.Counter(s)

print((sum((v*(v-1))//2 for v in list(c.values()))))
N = int(eval(input()))
dictionary = {}
count = 0
for i in range(N):
    s = str(sorted(eval(input())))
    if s in dictionary:
        dictionary[s] += 1
        count += dictionary[s]
    else:
        dictionary[s] = 0
print(count)

import collections

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

+import collections + -dictionary = {} -count = 0 -for i in range(N): -    s = str(sorted(eval(input()))) -    if s in dictionary: -        dictionary[s] += 1 -        count += dictionary[s] -    else: -        dictionary[s] = 0 -print(count) +s = [str(sorted(eval(input()))) for i in range(N)] +c = collections.Counter(s) +print((sum((v * (v - 1)) // 2 for v in list(c.values()))))