N = int(eval(input()))

s = sorted(sorted(eval(input())) for _ in range(N))

ans = 0

cnt = 1

for i in range(1, N):

    if s[i-1] == s[i]:

        cnt += 1

    else:

        if cnt > 1:

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

        cnt = 1

if cnt > 1:

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

print(ans)
import sys

N = int(eval(input()))

counts = {}

for _ in range(N):

    s = tuple(sorted(sys.stdin.readline()))

    counts[s] = counts.get(s, 0) + 1

ans = 0

for count in list(counts.values()):

    if count > 1:

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

print(ans)
N = int(eval(input()))
s = sorted(sorted(eval(input())) for _ in range(N))
ans = 0
cnt = 1
for i in range(1, N):
    if s[i - 1] == s[i]:
        cnt += 1
    else:
        if cnt > 1:
            ans += cnt * (cnt - 1) // 2
        cnt = 1
if cnt > 1:
    ans += cnt * (cnt - 1) // 2
print(ans)

import sys

N = int(eval(input()))
counts = {}
for _ in range(N):
    s = tuple(sorted(sys.stdin.readline()))
    counts[s] = counts.get(s, 0) + 1
ans = 0
for count in list(counts.values()):
    if count > 1:
        ans += count * (count - 1) // 2
print(ans)

+import sys + -s = sorted(sorted(eval(input())) for _ in range(N)) +counts = {} +for _ in range(N): +    s = tuple(sorted(sys.stdin.readline())) +    counts[s] = counts.get(s, 0) + 1 -cnt = 1 -for i in range(1, N): -    if s[i - 1] == s[i]: -        cnt += 1 -    else: -        if cnt > 1: -            ans += cnt * (cnt - 1) // 2 -        cnt = 1 -if cnt > 1: -    ans += cnt * (cnt - 1) // 2 +for count in list(counts.values()): +    if count > 1: +        ans += count * (count - 1) // 2