from collections import Counter



N = int(eval(input()))

S = []

for _ in range(N):

    s = list(eval(input()))

    s.sort()

    s = ''.join(s)

    S.append(s)



counter = Counter(S)



ans = 0

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

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

print(ans)

from collections import Counter



N = int(eval(input()))

S = [''.join(sorted(eval(input()))) for _ in range(N)]

counter = Counter(S)



ans = 0

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

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

print(ans)

from collections import Counter

N = int(eval(input()))
S = []
for _ in range(N):
    s = list(eval(input()))
    s.sort()
    s = "".join(s)
    S.append(s)
counter = Counter(S)
ans = 0
for v in list(counter.values()):
    ans += v * (v - 1) // 2
print(ans)

from collections import Counter

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

-S = [] -for _ in range(N): -    s = list(eval(input())) -    s.sort() -    s = "".join(s) -    S.append(s) +S = ["".join(sorted(eval(input()))) for _ in range(N)]