from collections import defaultdict

Sdic = defaultdict(int)



N = int(eval(input()))

S = ['']* N

ans = 0

for i in range(N):

    Sdic[str(sorted(eval(input())))] += 1



for i in list(Sdic.keys()):

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



print(ans)

import collections

N = int(eval(input()))



t = collections.defaultdict(int)

ans = 0



for _ in range(N):

    s = list(eval(input()))

    s.sort()

    t[''.join(s)] += 1





for x in t:

    ans += (t[x] * (t[x] - 1)) // 2



print(ans)

from collections import defaultdict

Sdic = defaultdict(int)
N = int(eval(input()))
S = [""] * N
ans = 0
for i in range(N):
    Sdic[str(sorted(eval(input())))] += 1
for i in list(Sdic.keys()):
    ans += (Sdic[i] * (Sdic[i] - 1)) // 2
print(ans)

import collections

N = int(eval(input()))
t = collections.defaultdict(int)
ans = 0
for _ in range(N):
    s = list(eval(input()))
    s.sort()
    t["".join(s)] += 1
for x in t:
    ans += (t[x] * (t[x] - 1)) // 2
print(ans)

-from collections import defaultdict +import collections -Sdic = defaultdict(int) -S = [""] * N +t = collections.defaultdict(int) -for i in range(N): -    Sdic[str(sorted(eval(input())))] += 1 -for i in list(Sdic.keys()): -    ans += (Sdic[i] * (Sdic[i] - 1)) // 2 +for _ in range(N): +    s = list(eval(input())) +    s.sort() +    t["".join(s)] += 1 +for x in t: +    ans += (t[x] * (t[x] - 1)) // 2