Buggy python submission (verdict: Runtime Error):
#from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(soted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)

Fixed submission:
from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(sorted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
lst = [Counter(input()) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)
cnt = 0
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
print(cnt)

Fixed submission:
from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(sorted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)