import collections

N=int(eval(input()))

S=[list(eval(input())) for i in range(N)]

x=[]

ans=0

for i in S:

  a=sorted(i)

  a="".join(a)

  x.append(a)

x=collections.Counter(x)

for i in list(x.values()):

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

print((int(ans)))

  
import collections

N=int(eval(input()))

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

S=[]

ans=0

for i in s:

  a=sorted(i)

  a="".join(a)

  S.append(a)

c=collections.Counter(S)

d=list(map(int,list(c.values())))

for i in d:

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

print((int(ans)))

  

import collections

N = int(eval(input()))
S = [list(eval(input())) for i in range(N)]
x = []
ans = 0
for i in S:
    a = sorted(i)
    a = "".join(a)
    x.append(a)
x = collections.Counter(x)
for i in list(x.values()):
    ans += i * (i - 1) / 2
print((int(ans)))

import collections

N = int(eval(input()))
s = [eval(input()) for i in range(N)]
S = []
ans = 0
for i in s:
    a = sorted(i)
    a = "".join(a)
    S.append(a)
c = collections.Counter(S)
d = list(map(int, list(c.values())))
for i in d:
    ans += i * (i - 1) / 2
print((int(ans)))

-S = [list(eval(input())) for i in range(N)] -x = [] +s = [eval(input()) for i in range(N)] +S = [] -for i in S: +for i in s: -    x.append(a) -x = collections.Counter(x) -for i in list(x.values()): +    S.append(a) +c = collections.Counter(S) +d = list(map(int, list(c.values()))) +for i in d: