import math

from collections import Counter



N = int(eval(input()))



s = []

for _ in range(N):

  s.append(''.join(sorted(str(eval(input())))))

  

c = Counter(s) 



def combinations_count(n, r):

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))



cnt = 0  

for i in list(c.values()):

  if i >= 2:

    cnt += combinations_count(i, 2)



print(cnt)
from collections import Counter



N = int(eval(input()))



s = []

for _ in range(N):

  s.append(''.join(sorted(str(eval(input())))))

  

c = Counter(s) 



cnt = 0  

for i in list(c.values()):

  if i >= 2:

    cnt += (i*(i-1))//2



print(cnt)
import math
from collections import Counter

N = int(eval(input()))
s = []
for _ in range(N):
    s.append("".join(sorted(str(eval(input())))))
c = Counter(s)


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


cnt = 0
for i in list(c.values()):
    if i >= 2:
        cnt += combinations_count(i, 2)
print(cnt)

from collections import Counter

N = int(eval(input()))
s = []
for _ in range(N):
    s.append("".join(sorted(str(eval(input())))))
c = Counter(s)
cnt = 0
for i in list(c.values()):
    if i >= 2:
        cnt += (i * (i - 1)) // 2
print(cnt)

-import math - - -def combinations_count(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - - -        cnt += combinations_count(i, 2) +        cnt += (i * (i - 1)) // 2