n = int(eval(input()))

sl = sorted([''.join(sorted(eval(input()))) for _ in [0]*n])

count = 0

while len(sl)>1:

  i = 1

  flag = True

  while flag:

    if sl[-1] == sl[-(i+1)]:

      i += 1

      if i == len(sl):

        flag=False

    else:

      flag = False

  if i>1:

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

  del sl[-i:]

  flag=True

print(count)

n = int(eval(input()))

sl = [eval(input()) for _ in [0]*n]

count = 0

dict = {}

for s_raw in sl:

  s = ''.join(sorted(s_raw))

  if s in dict:

    count += dict[s]

    dict[s] += 1

  else:

    dict.setdefault(s, 1)

print(count)
n = int(eval(input()))
sl = sorted(["".join(sorted(eval(input()))) for _ in [0] * n])
count = 0
while len(sl) > 1:
    i = 1
    flag = True
    while flag:
        if sl[-1] == sl[-(i + 1)]:
            i += 1
            if i == len(sl):
                flag = False
        else:
            flag = False
    if i > 1:
        count += i * (i - 1) // 2
    del sl[-i:]
    flag = True
print(count)

n = int(eval(input()))
sl = [eval(input()) for _ in [0] * n]
count = 0
dict = {}
for s_raw in sl:
    s = "".join(sorted(s_raw))
    if s in dict:
        count += dict[s]
        dict[s] += 1
    else:
        dict.setdefault(s, 1)
print(count)

-sl = sorted(["".join(sorted(eval(input()))) for _ in [0] * n]) +sl = [eval(input()) for _ in [0] * n] -while len(sl) > 1: -    i = 1 -    flag = True -    while flag: -        if sl[-1] == sl[-(i + 1)]: -            i += 1 -            if i == len(sl): -                flag = False -        else: -            flag = False -    if i > 1: -        count += i * (i - 1) // 2 -    del sl[-i:] -    flag = True +dict = {} +for s_raw in sl: +    s = "".join(sorted(s_raw)) +    if s in dict: +        count += dict[s] +        dict[s] += 1 +    else: +        dict.setdefault(s, 1)