n=int(eval(input()))

d=[list(eval(input())) for i in range(n)]

count=0

ans=0

for i in range(n):

  d[i].sort()

d.sort()



for i in range(n-1):

  if d[i]==d[i+1]:

    count+=1

  elif d[i]!=d[i+1]:

    x=count+1

    count=0

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

  if i==(n-2):

    x=count+1

    count=0

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

  

print((int(ans)))
n=int(eval(input()))

d=[]

for i in range(n):

  s=list(eval(input()))

  s.sort()

  s="".join(s)

  d.append(s)

d.sort()

x=[]

k=1



for i in range(n-1):

  if d[i]==d[i+1]:

    k+=1

  else:

    x.append(k)

    k=1

x.append(k)



ans=[]

for i in range(len(x)):

  if x[i]>1:

    ans.append((x[i]*(x[i]-1))/2)

  else:

    ans.append(0)

    

    

print((int(sum(ans))))
n = int(eval(input()))
d = [list(eval(input())) for i in range(n)]
count = 0
ans = 0
for i in range(n):
    d[i].sort()
d.sort()
for i in range(n - 1):
    if d[i] == d[i + 1]:
        count += 1
    elif d[i] != d[i + 1]:
        x = count + 1
        count = 0
        ans += (x * (x - 1)) / 2
    if i == (n - 2):
        x = count + 1
        count = 0
        ans += (x * (x - 1)) / 2
print((int(ans)))

n = int(eval(input()))
d = []
for i in range(n):
    s = list(eval(input()))
    s.sort()
    s = "".join(s)
    d.append(s)
d.sort()
x = []
k = 1
for i in range(n - 1):
    if d[i] == d[i + 1]:
        k += 1
    else:
        x.append(k)
        k = 1
x.append(k)
ans = []
for i in range(len(x)):
    if x[i] > 1:
        ans.append((x[i] * (x[i] - 1)) / 2)
    else:
        ans.append(0)
print((int(sum(ans))))

-d = [list(eval(input())) for i in range(n)] -count = 0 -ans = 0 +d = [] -    d[i].sort() +    s = list(eval(input())) +    s.sort() +    s = "".join(s) +    d.append(s) +x = [] +k = 1 -        count += 1 -    elif d[i] != d[i + 1]: -        x = count + 1 -        count = 0 -        ans += (x * (x - 1)) / 2 -    if i == (n - 2): -        x = count + 1 -        count = 0 -        ans += (x * (x - 1)) / 2 -print((int(ans))) +        k += 1 +    else: +        x.append(k) +        k = 1 +x.append(k) +ans = [] +for i in range(len(x)): +    if x[i] > 1: +        ans.append((x[i] * (x[i] - 1)) / 2) +    else: +        ans.append(0) +print((int(sum(ans))))