from collections import Counter



n = int(eval(input()))

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

c = Counter(s)



cnt = 0



for key in c:

    val = c[key]

    cnt += val*(val-1)//2



print(cnt)
from collections import Counter

n = int(eval(input()))

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

    

c = Counter(l)

cnt = 0

for val in list(c.values()):

    cnt += val * (val-1) //2



print(cnt)
from collections import Counter

n = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(n)]
c = Counter(s)
cnt = 0
for key in c:
    val = c[key]
    cnt += val * (val - 1) // 2
print(cnt)

from collections import Counter

n = int(eval(input()))
l = ["".join(sorted(eval(input()))) for i in range(n)]
c = Counter(l)
cnt = 0
for val in list(c.values()):
    cnt += val * (val - 1) // 2
print(cnt)

-s = ["".join(sorted(eval(input()))) for _ in range(n)] -c = Counter(s) +l = ["".join(sorted(eval(input()))) for i in range(n)] +c = Counter(l) -for key in c: -    val = c[key] +for val in list(c.values()):