N=int(eval(input()))

dictionary={}

count=0

for i in range(N):

    s="".join(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()))

ans=0

s=["".join(sorted(eval(input()))) for _ in range(n)]

c=collections.Counter(s)

for i in set(s):

  a=c[i]

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

print(ans)

N = int(eval(input()))
dictionary = {}
count = 0
for i in range(N):
    s = "".join(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()))
ans = 0
s = ["".join(sorted(eval(input()))) for _ in range(n)]
c = collections.Counter(s)
for i in set(s):
    a = c[i]
    ans += a * (a - 1) // 2
print(ans)

-N = int(eval(input())) -dictionary = {} -count = 0 -for i in range(N): -    s = "".join(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())) +ans = 0 +s = ["".join(sorted(eval(input()))) for _ in range(n)] +c = collections.Counter(s) +for i in set(s): +    a = c[i] +    ans += a * (a - 1) // 2 +print(ans)