n = int(eval(input()))

sl = [''.join(sorted(eval(input()))) for _ in [0]*n]

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 = int(eval(input()))
sl = ["".join(sorted(eval(input()))) for _ in [0] * n]
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 = int(eval(input())) -sl = ["".join(sorted(eval(input()))) for _ in [0] * n] +( +    n, +    *sl, +) = ["".join(sorted(x)) for x in open(0).read().split()]