N=int(eval(input()))



s_dic={}

for i in range(N):

  s=list(eval(input()))

  s.sort()

  s_str="".join(s)

  

  if s_str in s_dic:

    s_dic[s_str]+=1

  else:

    s_dic[s_str]=1



#print(s_dic)

answer=0

for key in s_dic:

  answer+=(s_dic[key]*(s_dic[key]-1))//2



print(answer)
from collections import defaultdict

import sys

input=sys.stdin.readline

N=int(eval(input()))



s_dic=defaultdict(int)

for i in range(N):

  s=list(input().rstrip())

  s.sort()

  s_str="".join(s)

  s_dic[s_str]+=1

#print(s_dic)



answer=0

for val in list(s_dic.values()):

  answer+=(val*(val-1))//2



print(answer)
N = int(eval(input()))
s_dic = {}
for i in range(N):
    s = list(eval(input()))
    s.sort()
    s_str = "".join(s)
    if s_str in s_dic:
        s_dic[s_str] += 1
    else:
        s_dic[s_str] = 1
# print(s_dic)
answer = 0
for key in s_dic:
    answer += (s_dic[key] * (s_dic[key] - 1)) // 2
print(answer)

from collections import defaultdict
import sys

input = sys.stdin.readline
N = int(eval(input()))
s_dic = defaultdict(int)
for i in range(N):
    s = list(input().rstrip())
    s.sort()
    s_str = "".join(s)
    s_dic[s_str] += 1
# print(s_dic)
answer = 0
for val in list(s_dic.values()):
    answer += (val * (val - 1)) // 2
print(answer)

+from collections import defaultdict +import sys + +input = sys.stdin.readline -s_dic = {} +s_dic = defaultdict(int) -    s = list(eval(input())) +    s = list(input().rstrip()) -    if s_str in s_dic: -        s_dic[s_str] += 1 -    else: -        s_dic[s_str] = 1 +    s_dic[s_str] += 1 -for key in s_dic: -    answer += (s_dic[key] * (s_dic[key] - 1)) // 2 +for val in list(s_dic.values()): +    answer += (val * (val - 1)) // 2