n=int(eval(input()))

ans=0

s=[[x for x in eval(input())] for i in range(n)]



dic={}

for i in s:

  temp=tuple(sorted(i))

  if temp in dic:

    ans+=dic[temp]

    dic[temp]+=1

  else:

    dic[temp]=1

print(ans)
import collections



ans=0

dic={}

n=int(eval(input()))

for i in range(n):

  s=eval(input())

  sl=[i for i in s]

  sl.sort()

  ss=tuple(sl)



  if ss not in dic:

    dic[ss]=1

  else:

    ans+=dic[ss]

    dic[ss]+=1



print(ans)
n = int(eval(input()))
ans = 0
s = [[x for x in eval(input())] for i in range(n)]
dic = {}
for i in s:
    temp = tuple(sorted(i))
    if temp in dic:
        ans += dic[temp]
        dic[temp] += 1
    else:
        dic[temp] = 1
print(ans)

import collections

ans = 0
dic = {}
n = int(eval(input()))
for i in range(n):
    s = eval(input())
    sl = [i for i in s]
    sl.sort()
    ss = tuple(sl)
    if ss not in dic:
        dic[ss] = 1
    else:
        ans += dic[ss]
        dic[ss] += 1
print(ans)

+import collections + +ans = 0 +dic = {} -ans = 0 -s = [[x for x in eval(input())] for i in range(n)] -dic = {} -for i in s: -    temp = tuple(sorted(i)) -    if temp in dic: -        ans += dic[temp] -        dic[temp] += 1 +for i in range(n): +    s = eval(input()) +    sl = [i for i in s] +    sl.sort() +    ss = tuple(sl) +    if ss not in dic: +        dic[ss] = 1 -        dic[temp] = 1 +        ans += dic[ss] +        dic[ss] += 1