#n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())

n = int(eval(input()))

sl = []

for i in range(n):

  S = ''.join(sorted(eval(input())))

  sl.append(S)

count = 0

dict ={}



for s in sl:

  if s in dict:

    count += dict[s]

    dict[s] += 1

  else:

    dict[s] = 1

print(count)
n,*sl, = [''.join(sorted(x)) for x in open(0).read().split()]

count = 0

dict ={}



for s in sl:

  if s in dict:

    count += dict[s]

    dict[s] += 1

  else:

    dict[s] = 1

print(count)
# n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
n = int(eval(input()))
sl = []
for i in range(n):
    S = "".join(sorted(eval(input())))
    sl.append(S)
count = 0
dict = {}
for s in sl:
    if s in dict:
        count += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(count)

(
    n,
    *sl,
) = ["".join(sorted(x)) for x in open(0).read().split()]
count = 0
dict = {}
for s in sl:
    if s in dict:
        count += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(count)

-# n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split()) -n = int(eval(input())) -sl = [] -for i in range(n): -    S = "".join(sorted(eval(input()))) -    sl.append(S) +( +    n, +    *sl, +) = ["".join(sorted(x)) for x in open(0).read().split()]