from collections import Counter

c = Counter(tuple(sorted(Counter(eval(input())).items())) for _ in range(int(eval(input()))))

print((sum(x * (x - 1) // 2 for x in list(c.values()))))

from collections import Counter

c = Counter(tuple(sorted(eval(input()))) for _ in range(int(eval(input()))))

print((sum(x * (x - 1) // 2 for x in list(c.values()))))

from collections import Counter

c = Counter(
    tuple(sorted(Counter(eval(input())).items())) for _ in range(int(eval(input())))
)
print((sum(x * (x - 1) // 2 for x in list(c.values()))))

from collections import Counter

c = Counter(tuple(sorted(eval(input()))) for _ in range(int(eval(input()))))
print((sum(x * (x - 1) // 2 for x in list(c.values()))))

-c = Counter( -    tuple(sorted(Counter(eval(input())).items())) for _ in range(int(eval(input()))) -) +c = Counter(tuple(sorted(eval(input()))) for _ in range(int(eval(input()))))