n=int(eval(input()))

s=["".join(sorted(eval(input()))) for _ in range(n)]

d={}

ans = 0

for i in s:

	k = d.get(i, 0)

	ans += k

	if k == 0:

		d[i] = 1

	else:

		d[i] += 1

print(ans)
from collections import Counter

n = int(eval(input()))

s = ["".join(sorted(eval(input()))) for _ in range(n)]

k = Counter(s)

ans = 0

for i, j in k.most_common():

	ans += j*(j-1)//2

print(ans)
n = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(n)]
d = {}
ans = 0
for i in s:
    k = d.get(i, 0)
    ans += k
    if k == 0:
        d[i] = 1
    else:
        d[i] += 1
print(ans)

from collections import Counter

n = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(n)]
k = Counter(s)
ans = 0
for i, j in k.most_common():
    ans += j * (j - 1) // 2
print(ans)

+from collections import Counter + -d = {} +k = Counter(s) -for i in s: -    k = d.get(i, 0) -    ans += k -    if k == 0: -        d[i] = 1 -    else: -        d[i] += 1 +for i, j in k.most_common(): +    ans += j * (j - 1) // 2