import math

def comb(n, r):

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))



n=int(eval(input()))

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

dic_l={}

cnt=0

ans_lst=[]

for i in range(n):

  l[i].sort()

  l[i]=str(l[i])

  if l[i] not in dic_l:

    dic_l[l[i]]=1

  else:

    dic_l[l[i]]+=1

for j in list(dic_l.values()):

  if j>=2:

    ans_lst.append(j)

    cnt += comb(j,2)

print(cnt)

n=int(eval(input()))

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

dic_l={}

cnt=0

ans_lst=[]

for i in range(n):

  l[i].sort()

  l[i]=str(l[i])

  if l[i] not in dic_l:

    dic_l[l[i]]=1

  else:

    dic_l[l[i]]+=1

for j in list(dic_l.values()):

  if j>=2:

    ans_lst.append(j)

    cnt += int(j*(j-1)/2)

print(cnt)
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(eval(input()))
l = [list(eval(input())) for _ in range(n)]
dic_l = {}
cnt = 0
ans_lst = []
for i in range(n):
    l[i].sort()
    l[i] = str(l[i])
    if l[i] not in dic_l:
        dic_l[l[i]] = 1
    else:
        dic_l[l[i]] += 1
for j in list(dic_l.values()):
    if j >= 2:
        ans_lst.append(j)
        cnt += comb(j, 2)
print(cnt)

n = int(eval(input()))
l = [list(eval(input())) for _ in range(n)]
dic_l = {}
cnt = 0
ans_lst = []
for i in range(n):
    l[i].sort()
    l[i] = str(l[i])
    if l[i] not in dic_l:
        dic_l[l[i]] = 1
    else:
        dic_l[l[i]] += 1
for j in list(dic_l.values()):
    if j >= 2:
        ans_lst.append(j)
        cnt += int(j * (j - 1) / 2)
print(cnt)

-import math - - -def comb(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - - -        cnt += comb(j, 2) +        cnt += int(j * (j - 1) / 2)