N = int(eval(input()))



lst = []

for _ in range(N):

    tmp = list(eval(input()))

    tmp.sort()

    lst.append(tmp)

lst.sort()

tmp = lst[0]

count = 1

ans = 0

for i in range(1, N):

    if tmp == lst[i]:

        count += 1

    else:

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

        count = 1

        tmp = lst[i]

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

print (ans)
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 9)

MOD = 10 ** 9 + 7



from collections import defaultdict



N = int(eval(input()))



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



for i in range(N):

    S[i].sort()



S.sort()

ans = 0

count = 1

for i in range(1, N):

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

        count += 1

    else:

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

        count = 1



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

print (ans)
N = int(eval(input()))
lst = []
for _ in range(N):
    tmp = list(eval(input()))
    tmp.sort()
    lst.append(tmp)
lst.sort()
tmp = lst[0]
count = 1
ans = 0
for i in range(1, N):
    if tmp == lst[i]:
        count += 1
    else:
        ans = ans + (count * (count - 1)) // 2
        count = 1
        tmp = lst[i]
ans = ans + (count * (count - 1)) // 2
print(ans)

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9 + 7
from collections import defaultdict

N = int(eval(input()))
S = [list(eval(input())) for _ in range(N)]
for i in range(N):
    S[i].sort()
S.sort()
ans = 0
count = 1
for i in range(1, N):
    if S[i - 1] == S[i]:
        count += 1
    else:
        ans += count * (count - 1) // 2
        count = 1
ans += count * (count - 1) // 2
print(ans)

+import sys + +input = sys.stdin.readline +sys.setrecursionlimit(10**9) +MOD = 10**9 + 7 +from collections import defaultdict + -lst = [] -for _ in range(N): -    tmp = list(eval(input())) -    tmp.sort() -    lst.append(tmp) -lst.sort() -tmp = lst[0] +S = [list(eval(input())) for _ in range(N)] +for i in range(N): +    S[i].sort() +S.sort() +ans = 0 -ans = 0 -    if tmp == lst[i]: +    if S[i - 1] == S[i]: -        ans = ans + (count * (count - 1)) // 2 +        ans += count * (count - 1) // 2 -        tmp = lst[i] -ans = ans + (count * (count - 1)) // 2 +ans += count * (count - 1) // 2