from scipy.misc import comb

n = int(eval(input()))

dic = {}

for _ in range(n):

  s = eval(input())

  tmp = [0]*26

  for i in s:

    tmp[ord(i)-97] += 1

  tmp = tuple(tmp)

  if tmp in dic:

    dic[tmp] += 1

  else:

    dic[tmp] = 1

total = 0

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

  if i<2:

    continue

  total += comb(i, 2, exact=True)

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

s = []

for _ in range(n):

    s.append(eval(input()))

di = {}

for i in s:

    tmp = [0]*26

    for c in i:

        tmp[ord(c)-ord('a')] += 1

    tmp = tuple(tmp)

    if tmp in di:

        di[tmp] += 1

    else:

        di[tmp] = 1



ans = 0

for i in list(di.values()):

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

print(ans)

from scipy.misc import comb

n = int(eval(input()))
dic = {}
for _ in range(n):
    s = eval(input())
    tmp = [0] * 26
    for i in s:
        tmp[ord(i) - 97] += 1
    tmp = tuple(tmp)
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1
total = 0
for i in list(dic.values()):
    if i < 2:
        continue
    total += comb(i, 2, exact=True)
print(total)

n = int(eval(input()))
s = []
for _ in range(n):
    s.append(eval(input()))
di = {}
for i in s:
    tmp = [0] * 26
    for c in i:
        tmp[ord(c) - ord("a")] += 1
    tmp = tuple(tmp)
    if tmp in di:
        di[tmp] += 1
    else:
        di[tmp] = 1
ans = 0
for i in list(di.values()):
    ans += i * (i - 1) // 2
print(ans)

-from scipy.misc import comb - -dic = {} +s = [] -    s = eval(input()) +    s.append(eval(input())) +di = {} +for i in s: -    for i in s: -        tmp[ord(i) - 97] += 1 +    for c in i: +        tmp[ord(c) - ord("a")] += 1 -    if tmp in dic: -        dic[tmp] += 1 +    if tmp in di: +        di[tmp] += 1 -        dic[tmp] = 1 -total = 0 -for i in list(dic.values()): -    if i < 2: -        continue -    total += comb(i, 2, exact=True) -print(total) +        di[tmp] = 1 +ans = 0 +for i in list(di.values()): +    ans += i * (i - 1) // 2 +print(ans)