n=int(eval(input()))

s=[None]*n

for i in range(n):

  s[i]="".join(sorted(eval(input())))



s=sorted(s)



total=0

count=1

for j in range(1,n):

  if s[j]==s[j-1]:

    count = count+1

  else:

    if count>1:

      total = total+(count*(count-1))//2

    count=1



if count>1:

  total = total+(count*(count-1))//2



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

s=[None]*n

for i in range(n):

  s[i]="".join(sorted(eval(input())))

import collections

c=collections.Counter(s)

ans=0

for v in list(c.values()):

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

print(ans)
n = int(eval(input()))
s = [None] * n
for i in range(n):
    s[i] = "".join(sorted(eval(input())))
s = sorted(s)
total = 0
count = 1
for j in range(1, n):
    if s[j] == s[j - 1]:
        count = count + 1
    else:
        if count > 1:
            total = total + (count * (count - 1)) // 2
        count = 1
if count > 1:
    total = total + (count * (count - 1)) // 2
print(total)

n = int(eval(input()))
s = [None] * n
for i in range(n):
    s[i] = "".join(sorted(eval(input())))
import collections

c = collections.Counter(s)
ans = 0
for v in list(c.values()):
    ans += (v * (v - 1)) // 2
print(ans)

-s = sorted(s) -total = 0 -count = 1 -for j in range(1, n): -    if s[j] == s[j - 1]: -        count = count + 1 -    else: -        if count > 1: -            total = total + (count * (count - 1)) // 2 -        count = 1 -if count > 1: -    total = total + (count * (count - 1)) // 2 -print(total) +import collections + +c = collections.Counter(s) +ans = 0 +for v in list(c.values()): +    ans += (v * (v - 1)) // 2 +print(ans)