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(''.join(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(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("".join(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(eval(input()))) for _ in range(int(eval(input())))) +c = Counter("".join(sorted(eval(input()))) for _ in range(int(eval(input()))))