import collections



n=int(eval(input()))

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

dic={}

for s in arr:

  count=[0]*26

  tmp=collections.Counter(s)

  for char in list(tmp.keys()):

    count[ord(char)-ord('a')]+=tmp[char]

  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()))

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

dic={}

alphabet='abcdefghijklmnopqrstuvwxyz'

for s in arr:

  count=[0]*26

  for i in range(10):

    for j in range(26):

      if s[i]==alphabet[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)
import collections

n = int(eval(input()))
arr = [eval(input()) for _ in range(n)]
dic = {}
for s in arr:
    count = [0] * 26
    tmp = collections.Counter(s)
    for char in list(tmp.keys()):
        count[ord(char) - ord("a")] += tmp[char]
    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()))
arr = [eval(input()) for _ in range(n)]
dic = {}
alphabet = "abcdefghijklmnopqrstuvwxyz"
for s in arr:
    count = [0] * 26
    for i in range(10):
        for j in range(26):
            if s[i] == alphabet[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)

-import collections - +alphabet = "abcdefghijklmnopqrstuvwxyz" -    tmp = collections.Counter(s) -    for char in list(tmp.keys()): -        count[ord(char) - ord("a")] += tmp[char] +    for i in range(10): +        for j in range(26): +            if s[i] == alphabet[j]: +                count[j] += 1 +                break