from collections import defaultdict, Counter





N = int(eval(input()))

dic = defaultdict(int)

ans = 0

for _ in range(N):

    elem = [(k, v) for k, v in list(Counter(eval(input())).items())]

    elem = tuple(sorted(elem))

    ans += dic[elem]

    dic[elem] += 1

print(ans)

from collections import defaultdict





N = int(eval(input()))

dic = defaultdict(int)

ans = 0

for _ in range(N):

    elem = str(sorted(eval(input())))

    ans += dic[elem]

    dic[elem] += 1

print(ans)

from collections import defaultdict, Counter

N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
    elem = [(k, v) for k, v in list(Counter(eval(input())).items())]
    elem = tuple(sorted(elem))
    ans += dic[elem]
    dic[elem] += 1
print(ans)

from collections import defaultdict

N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
    elem = str(sorted(eval(input())))
    ans += dic[elem]
    dic[elem] += 1
print(ans)

-from collections import defaultdict, Counter +from collections import defaultdict -    elem = [(k, v) for k, v in list(Counter(eval(input())).items())] -    elem = tuple(sorted(elem)) +    elem = str(sorted(eval(input())))