c = {}

n = int(eval(input()))

r = 0

for _ in range(n):

    s = ''.join(sorted(eval(input())))

    v = c.get(s, 0)

    r += v

    c[s] = v + 1

print(r)

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 = {}
n = int(eval(input()))
r = 0
for _ in range(n):
    s = "".join(sorted(eval(input())))
    v = c.get(s, 0)
    r += v
    c[s] = v + 1
print(r)

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 = {} -n = int(eval(input())) -r = 0 -for _ in range(n): -    s = "".join(sorted(eval(input()))) -    v = c.get(s, 0) -    r += v -    c[s] = v + 1 -print(r) +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()))))