import itertools

import collections

N = int(eval(input()))

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

S = [''.join(sorted(x)) for x in S]



cnt=0

reg = collections.defaultdict(int)

for s in S:

    reg[s] += 1

    if reg[s] > 1:

        cnt += reg[s] - 1

print(cnt)
import collections



N = int(eval(input()))

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

S = [''.join(sorted(x)) for x in S]

S = collections.Counter(S)



ans = [x*(x-1)//2 for x in list(S.values())]

print((sum(ans)))
import itertools
import collections

N = int(eval(input()))
S = [[str(x) for x in eval(input())] for _ in range(N)]
S = ["".join(sorted(x)) for x in S]
cnt = 0
reg = collections.defaultdict(int)
for s in S:
    reg[s] += 1
    if reg[s] > 1:
        cnt += reg[s] - 1
print(cnt)

import collections

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
S = ["".join(sorted(x)) for x in S]
S = collections.Counter(S)
ans = [x * (x - 1) // 2 for x in list(S.values())]
print((sum(ans)))

-import itertools -S = [[str(x) for x in eval(input())] for _ in range(N)] +S = [eval(input()) for _ in range(N)] -cnt = 0 -reg = collections.defaultdict(int) -for s in S: -    reg[s] += 1 -    if reg[s] > 1: -        cnt += reg[s] - 1 -print(cnt) +S = collections.Counter(S) +ans = [x * (x - 1) // 2 for x in list(S.values())] +print((sum(ans)))