n = int(eval(input()))

S = ["".join(list(sorted(eval(input())))) for _ in range(n)]

d = {}

for i in S:

    d.setdefault(i, 0)

    d[i] += 1

ans = 0

for value in list(d.values()):

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

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

S = [''.join(sorted(eval(input()))) for _ in range(n)]

d = {}

for i in S:

    d.setdefault(i, 0)

    d[i] += 1

ans = 0

for value in list(d.values()):

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

print(ans)
n = int(eval(input()))
S = ["".join(list(sorted(eval(input())))) for _ in range(n)]
d = {}
for i in S:
    d.setdefault(i, 0)
    d[i] += 1
ans = 0
for value in list(d.values()):
    ans += value * (value - 1) / 2
print((int(ans)))

n = int(eval(input()))
S = ["".join(sorted(eval(input()))) for _ in range(n)]
d = {}
for i in S:
    d.setdefault(i, 0)
    d[i] += 1
ans = 0
for value in list(d.values()):
    ans += value * (value - 1) // 2
print(ans)

-S = ["".join(list(sorted(eval(input())))) for _ in range(n)] +S = ["".join(sorted(eval(input()))) for _ in range(n)] -    ans += value * (value - 1) / 2 -print((int(ans))) +    ans += value * (value - 1) // 2 +print(ans)