n=int(eval(input()))

l=[]

for i in range(n):

  w=sorted(list(eval(input())))

  l.append(w)

l=sorted(l)

c=0

c1=0

w1=l[0]

for i in range(n):

  if w1==l[i]:

    c1+=1

  else:

    w1=l[i]

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

    c1=1

    

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

print(c)
from collections import defaultdict

n=int(eval(input()))

l=defaultdict(int)

for i in range(n):

  l1=sorted(list(eval(input())))

  w1="".join(l1)

  l[w1]+=1

count=0

for i in l:

  if l[i]!=1:

    count+=l[i]*(l[i]-1)//2

print(count)
n = int(eval(input()))
l = []
for i in range(n):
    w = sorted(list(eval(input())))
    l.append(w)
l = sorted(l)
c = 0
c1 = 0
w1 = l[0]
for i in range(n):
    if w1 == l[i]:
        c1 += 1
    else:
        w1 = l[i]
        c += c1 * (c1 - 1) // 2
        c1 = 1
c += c1 * (c1 - 1) // 2
print(c)

from collections import defaultdict

n = int(eval(input()))
l = defaultdict(int)
for i in range(n):
    l1 = sorted(list(eval(input())))
    w1 = "".join(l1)
    l[w1] += 1
count = 0
for i in l:
    if l[i] != 1:
        count += l[i] * (l[i] - 1) // 2
print(count)

+from collections import defaultdict + -l = [] +l = defaultdict(int) -    w = sorted(list(eval(input()))) -    l.append(w) -l = sorted(l) -c = 0 -c1 = 0 -w1 = l[0] -for i in range(n): -    if w1 == l[i]: -        c1 += 1 -    else: -        w1 = l[i] -        c += c1 * (c1 - 1) // 2 -        c1 = 1 -c += c1 * (c1 - 1) // 2 -print(c) +    l1 = sorted(list(eval(input()))) +    w1 = "".join(l1) +    l[w1] += 1 +count = 0 +for i in l: +    if l[i] != 1: +        count += l[i] * (l[i] - 1) // 2 +print(count)