from collections import Counter

N = int(eval(input()))

S = [str(sorted(eval(input()))) for _ in range(N)]

count = 0

for i in list(Counter(S).values()):

  count += i*(i-1)//2

print(count)
from collections import Counter

N = int(eval(input()))

S = [eval(input()) for _ in range(N)]

ans = 0

check_box = []

for s in S:

  s = sorted(s)

  s = ''.join(s)

  check_box.append(s)

C = Counter(check_box)

for i in C:

  ans += C[i]*(C[i]-1)//2

print(ans)
from collections import Counter

N = int(eval(input()))
S = [str(sorted(eval(input()))) for _ in range(N)]
count = 0
for i in list(Counter(S).values()):
    count += i * (i - 1) // 2
print(count)

from collections import Counter

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
ans = 0
check_box = []
for s in S:
    s = sorted(s)
    s = "".join(s)
    check_box.append(s)
C = Counter(check_box)
for i in C:
    ans += C[i] * (C[i] - 1) // 2
print(ans)

-S = [str(sorted(eval(input()))) for _ in range(N)] -count = 0 -for i in list(Counter(S).values()): -    count += i * (i - 1) // 2 -print(count) +S = [eval(input()) for _ in range(N)] +ans = 0 +check_box = [] +for s in S: +    s = sorted(s) +    s = "".join(s) +    check_box.append(s) +C = Counter(check_box) +for i in C: +    ans += C[i] * (C[i] - 1) // 2 +print(ans)