from collections import defaultdict

n = int(eval(input()))

dic_sorted_s = defaultdict(int)

count = 0

for i in range(n):

    s = eval(input())

    str_sorted_s = ''.join(sorted(s))

    count += dic_sorted_s[str_sorted_s]

    dic_sorted_s[str_sorted_s] += 1

print(count)
from collections import Counter

n = int(eval(input()))

cnt_s = Counter([''.join(sorted(eval(input()))) for i in range(n)])

print((sum(v*(v - 1)//2 for v in list(cnt_s.values()))))
from collections import defaultdict

n = int(eval(input()))
dic_sorted_s = defaultdict(int)
count = 0
for i in range(n):
    s = eval(input())
    str_sorted_s = "".join(sorted(s))
    count += dic_sorted_s[str_sorted_s]
    dic_sorted_s[str_sorted_s] += 1
print(count)

from collections import Counter

n = int(eval(input()))
cnt_s = Counter(["".join(sorted(eval(input()))) for i in range(n)])
print((sum(v * (v - 1) // 2 for v in list(cnt_s.values()))))

-from collections import defaultdict +from collections import Counter -dic_sorted_s = defaultdict(int) -count = 0 -for i in range(n): -    s = eval(input()) -    str_sorted_s = "".join(sorted(s)) -    count += dic_sorted_s[str_sorted_s] -    dic_sorted_s[str_sorted_s] += 1 -print(count) +cnt_s = Counter(["".join(sorted(eval(input()))) for i in range(n)]) +print((sum(v * (v - 1) // 2 for v in list(cnt_s.values()))))