from collections import defaultdict

N = int(eval(input()))

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



d = defaultdict(int)

for s in S:

    d[''.join(sorted(s))] += 1

    

ans = 0

for v in list(d.values()):

    if v > 1:

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

print(ans)

from collections import defaultdict



N = int(eval(input()))

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



ctr = defaultdict(int)



for i in range(N):

    tmp = [0] * 26

    for j in range(10):

        tmp[ord(S[i][j]) - ord("a")] += 1

    ctr[tuple(tmp)] += 1



ans = 0

for v in list(ctr.values()):

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

print(ans)

from collections import defaultdict

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
d = defaultdict(int)
for s in S:
    d["".join(sorted(s))] += 1
ans = 0
for v in list(d.values()):
    if v > 1:
        ans += v * (v - 1) // 2
print(ans)

from collections import defaultdict

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
ctr = defaultdict(int)
for i in range(N):
    tmp = [0] * 26
    for j in range(10):
        tmp[ord(S[i][j]) - ord("a")] += 1
    ctr[tuple(tmp)] += 1
ans = 0
for v in list(ctr.values()):
    ans += v * (v - 1) // 2
print(ans)

-d = defaultdict(int) -for s in S: -    d["".join(sorted(s))] += 1 +ctr = defaultdict(int) +for i in range(N): +    tmp = [0] * 26 +    for j in range(10): +        tmp[ord(S[i][j]) - ord("a")] += 1 +    ctr[tuple(tmp)] += 1 -for v in list(d.values()): -    if v > 1: -        ans += v * (v - 1) // 2 +for v in list(ctr.values()): +    ans += v * (v - 1) // 2