N = int(eval(input()))

s = [eval(input()) for i in range(N)]



s_sorted = list(map(''.join, list(map(sorted, s))))



s_dict = dict()

for k in s_sorted:

    if k in s_dict:

        s_dict[k] += 1

    else:

        s_dict[k] = 1



#cnt = 0

# for k in s_dict:

#    cnt += sum(range(s_dict[k]))

cnt = sum([sum(range(s_dict[k])) for k in s_dict])



print(cnt)

N = int(eval(input()))

s = [eval(input()) for i in range(N)]



s_sorted = list(map(''.join, list(map(sorted, s))))



s_dict = dict()

cnt = 0

for k in s_sorted:

    if k in s_dict:

        cnt += s_dict[k]

        s_dict[k] += 1

    else:

        s_dict[k] = 1



#cnt = 0

# for k in s_dict:

#    cnt += sum(range(s_dict[k]))

#cnt = sum([sum(range(s_dict[k])) for k in s_dict])



print(cnt)
N = int(eval(input()))
s = [eval(input()) for i in range(N)]
s_sorted = list(map("".join, list(map(sorted, s))))
s_dict = dict()
for k in s_sorted:
    if k in s_dict:
        s_dict[k] += 1
    else:
        s_dict[k] = 1
# cnt = 0
# for k in s_dict:
#    cnt += sum(range(s_dict[k]))
cnt = sum([sum(range(s_dict[k])) for k in s_dict])
print(cnt)

N = int(eval(input()))
s = [eval(input()) for i in range(N)]
s_sorted = list(map("".join, list(map(sorted, s))))
s_dict = dict()
cnt = 0
for k in s_sorted:
    if k in s_dict:
        cnt += s_dict[k]
        s_dict[k] += 1
    else:
        s_dict[k] = 1
# cnt = 0
# for k in s_dict:
#    cnt += sum(range(s_dict[k]))
# cnt = sum([sum(range(s_dict[k])) for k in s_dict])
print(cnt)

+cnt = 0 +        cnt += s_dict[k] -cnt = sum([sum(range(s_dict[k])) for k in s_dict]) +# cnt = sum([sum(range(s_dict[k])) for k in s_dict])