n=int(eval(input()))

arr=[eval(input()) for _ in range(n)]

dic={}

check='abcdefghijklmnopqrstuvwxyz'

for s in arr:

  count=[0]*26

  for i in range(10):

    for j in range(26):

      if s[i]==check[j]:

        count[j]+=1

        break

  count=tuple(count)

  if count not in dic:

    dic[count]=1

  else:

    dic[count]+=1

ans=0

for val in list(dic.values()):

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

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

dic={}

ans=0

for _ in range(n):

  s=eval(input())

  s=str(sorted(s))

  if s not in dic:

    dic[s]=1

  else:

    ans+=dic[s]    

    dic[s]+=1

print(ans)
n = int(eval(input()))
arr = [eval(input()) for _ in range(n)]
dic = {}
check = "abcdefghijklmnopqrstuvwxyz"
for s in arr:
    count = [0] * 26
    for i in range(10):
        for j in range(26):
            if s[i] == check[j]:
                count[j] += 1
                break
    count = tuple(count)
    if count not in dic:
        dic[count] = 1
    else:
        dic[count] += 1
ans = 0
for val in list(dic.values()):
    ans += val * (val - 1) // 2
print(ans)

n = int(eval(input()))
dic = {}
ans = 0
for _ in range(n):
    s = eval(input())
    s = str(sorted(s))
    if s not in dic:
        dic[s] = 1
    else:
        ans += dic[s]
        dic[s] += 1
print(ans)

-arr = [eval(input()) for _ in range(n)] -check = "abcdefghijklmnopqrstuvwxyz" -for s in arr: -    count = [0] * 26 -    for i in range(10): -        for j in range(26): -            if s[i] == check[j]: -                count[j] += 1 -                break -    count = tuple(count) -    if count not in dic: -        dic[count] = 1 +ans = 0 +for _ in range(n): +    s = eval(input()) +    s = str(sorted(s)) +    if s not in dic: +        dic[s] = 1 -        dic[count] += 1 -ans = 0 -for val in list(dic.values()): -    ans += val * (val - 1) // 2 +        ans += dic[s] +        dic[s] += 1