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=tuple(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 = tuple(sorted(eval(input())))
    if s in dictionary:
        dictionary[s] += 1
        count += dictionary[s]
    else:
        dictionary[s] = 0
print(count)

-import collections - -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())))) +dictionary = {} +count = 0 +for i in range(N): +    s = tuple(sorted(eval(input()))) +    if s in dictionary: +        dictionary[s] += 1 +        count += dictionary[s] +    else: +        dictionary[s] = 0 +print(count)