Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)


Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input()
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)


Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
ans=0
dic={}
for s1 in s:
    s=sorted(s1)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)


Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[input() for _ in range(n)]
ans=0
dic={}
for i in range(n):
    a=s[i].sort()
    if not a in dic.keys():
      dic[a]=1
    else: dic[a]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)


Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
ans=0
dic={}
for i in range(n):
    lst=sorted(list(s[i]))
    a=''
    for k in lst:
        a+=k
    if not a in dic.keys():
      dic[a]=1
    else: dic[a]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[input() for _ in range(n)]
ans=0
dic=dict()
for i in range(n):
    lst=sorted(list(s[i]))
    if dic[lst]:
      dic[lst]=1
    else: dic[lst]+=1
for i in dic.values():
  ans+=i*(i-1)

    
print(ans)


Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n):
    lst=sorted(list(s[i]))
    for j in range(i+1,n):
        lst1=sorted(list(s[j]))
        if lst==lst1:
            ans+=1
print(ans)


Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n):
    lst=list(s[i])
    for j in range(i+1,n):
        lst1=list(s[j])
        for k in lst:
            for l in lst1:
                if k==l:
                    lst1.remove(l)
                    break
        if len(lst1)==0:
            ans+=1
print(ans)


Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    if s[i].count('a')!=s[j].count('a'):
        continue
    if s[i].count('b')!=s[j].count('b'):
        continue
    if s[i].count('c')!=s[j].count('c'):
        continue
    if s[i].count('d')!=s[j].count('d'):
        continue
    if s[i].count('e')!=s[j].count('e'):
        continue
    if s[i].count('f')!=s[j].count('f'):
        continue
    if s[i].count('g')!=s[j].count('g'):
        continue
    if s[i].count('h')!=s[j].count('h'):
        continue
    if s[i].count('i')!=s[j].count('i'):
        continue
    if s[i].count('j')!=s[j].count('j'):
        continue
    if s[i].count('k')!=s[j].count('k'):
        continue
    if s[i].count('l')!=s[j].count('l'):
        continue
    if s[i].count('m')!=s[j].count('m'):
        continue
    if s[i].count('n')!=s[j].count('n'):
        continue
    if s[i].count('o')!=s[j].count('o'):
        continue
    if s[i].count('p')!=s[j].count('p'):
        continue
    if s[i].count('q')!=s[j].count('q'):
        continue
    if s[i].count('r')!=s[j].count('r'):
        continue
    if s[i].count('s')!=s[j].count('s'):
        continue
    if s[i].count('t')!=s[j].count('t'):
        continue
    if s[i].count('u')!=s[j].count('u'):
        continue
    if s[i].count('v')!=s[j].count('v'):
        continue
    if s[i].count('w')!=s[j].count('w'):
        continue
    if s[i].count('x')!=s[j].count('x'):
        continue
    if s[i].count('y')!=s[j].count('y'):
        continue
    if s[i].count('z')!=s[j].count('z'):
        continue
    ans+=1
print(ans)

      

Fixed submission:
n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)