from operator import itemgetter



n=int(eval(input()))

s=[]

li=[]

ans=0

cnt=1



for i in range(n):

  s.append(sorted(eval(input())))

s.sort(key=itemgetter(9,8,7,6,5,4,3,2,1,0))

s=s+['']



for i in range(n):

  if s[i]==s[i+1]:

    cnt+=1

  elif cnt>1:

    li.append(int(cnt*(cnt-1)/2))

    cnt=1

  else:

    cnt=1

print((int(sum(li))))
from collections import defaultdict



n=int(eval(input()))

dct=defaultdict(int)



for i in range(n):

  s=eval(input())

  sort_s="".join(sorted(s))

  dct[sort_s]+=1

ans=0

for k,v in list(dct.items()):

  ans+= v*(v-1)//2

print(ans)
from operator import itemgetter

n = int(eval(input()))
s = []
li = []
ans = 0
cnt = 1
for i in range(n):
    s.append(sorted(eval(input())))
s.sort(key=itemgetter(9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
s = s + [""]
for i in range(n):
    if s[i] == s[i + 1]:
        cnt += 1
    elif cnt > 1:
        li.append(int(cnt * (cnt - 1) / 2))
        cnt = 1
    else:
        cnt = 1
print((int(sum(li))))

from collections import defaultdict

n = int(eval(input()))
dct = defaultdict(int)
for i in range(n):
    s = eval(input())
    sort_s = "".join(sorted(s))
    dct[sort_s] += 1
ans = 0
for k, v in list(dct.items()):
    ans += v * (v - 1) // 2
print(ans)

-from operator import itemgetter +from collections import defaultdict -s = [] -li = [] +dct = defaultdict(int) +for i in range(n): +    s = eval(input()) +    sort_s = "".join(sorted(s)) +    dct[sort_s] += 1 -cnt = 1 -for i in range(n): -    s.append(sorted(eval(input()))) -s.sort(key=itemgetter(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) -s = s + [""] -for i in range(n): -    if s[i] == s[i + 1]: -        cnt += 1 -    elif cnt > 1: -        li.append(int(cnt * (cnt - 1) / 2)) -        cnt = 1 -    else: -        cnt = 1 -print((int(sum(li)))) +for k, v in list(dct.items()): +    ans += v * (v - 1) // 2 +print(ans)