import math



N = int(eval(input()))

s = {}

ans = 0



for i in range(N):

    tmp = ''.join(sorted(eval(input())))

    if tmp in s:

        s[tmp] += 1

    else:

        s[tmp] = 1



x = math.factorial(2)

for n in list(s.values()):

  	if n > 1:

	    ans += math.factorial(n) // (math.factorial(n-2) * x)

print(ans)

from collections import Counter



count = Counter()

for i in range(int(eval(input()))):

	s = sorted(eval(input()))

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

	

ans = 0



for n in list(count.values()):

	if n >= 2:

		ans += (n**2 - n) // 2 

		

print(ans)
import math

N = int(eval(input()))
s = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(eval(input())))
    if tmp in s:
        s[tmp] += 1
    else:
        s[tmp] = 1
x = math.factorial(2)
for n in list(s.values()):
    if n > 1:
        ans += math.factorial(n) // (math.factorial(n - 2) * x)
print(ans)

from collections import Counter

count = Counter()
for i in range(int(eval(input()))):
    s = sorted(eval(input()))
    count["".join(s)] += 1
ans = 0
for n in list(count.values()):
    if n >= 2:
        ans += (n**2 - n) // 2
print(ans)

-import math +from collections import Counter -N = int(eval(input())) -s = {} +count = Counter() +for i in range(int(eval(input()))): +    s = sorted(eval(input())) +    count["".join(s)] += 1 -for i in range(N): -    tmp = "".join(sorted(eval(input()))) -    if tmp in s: -        s[tmp] += 1 -    else: -        s[tmp] = 1 -x = math.factorial(2) -for n in list(s.values()): -    if n > 1: -        ans += math.factorial(n) // (math.factorial(n - 2) * x) +for n in list(count.values()): +    if n >= 2: +        ans += (n**2 - n) // 2