from collections import defaultdict

import math



N = int(eval(input()))

li = [eval(input()) for i in range(N)]

d = defaultdict(int)



def combinations_count(n, r):

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



count = 0



for i in li:

  s = sorted(list(i))

  t = "".join(s)



  d[t] += 1



for i in d:

  if d[i] > 1:

    count += combinations_count(d[i], 2)

    

print(count)
from collections import defaultdict

import math



N = int(eval(input()))

li = [eval(input()) for i in range(N)]

d = defaultdict(int)



count = 0



for i in li:

  s = sorted(list(i))

  t = "".join(s)



  if d[t] != 0:

    count += d[t]

  d[t] += 1

    

print(count)
from collections import defaultdict
import math

N = int(eval(input()))
li = [eval(input()) for i in range(N)]
d = defaultdict(int)


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


count = 0
for i in li:
    s = sorted(list(i))
    t = "".join(s)
    d[t] += 1
for i in d:
    if d[i] > 1:
        count += combinations_count(d[i], 2)
print(count)

from collections import defaultdict
import math

N = int(eval(input()))
li = [eval(input()) for i in range(N)]
d = defaultdict(int)
count = 0
for i in li:
    s = sorted(list(i))
    t = "".join(s)
    if d[t] != 0:
        count += d[t]
    d[t] += 1
print(count)

- - -def combinations_count(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - - +    if d[t] != 0: +        count += d[t] -for i in d: -    if d[i] > 1: -        count += combinations_count(d[i], 2)