import collections

N = int(eval(input()))

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

mydict = {}

ans = 0

for i in s:

  a = str(sorted(i))

  if a in mydict:

    ans += mydict[a]

    mydict[a] += 1

  else:

    mydict.setdefault(a,1)

print(ans)
# C - Green Bin

# https://atcoder.jp/contests/abc137/tasks/abc137_c



from collections import Counter



n = int(eval(input()))

S = []

for _ in range(n):

  s = "".join(sorted(eval(input())))

  S.append(s)



C = Counter(S)



ans = 0

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

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



print(ans)
import collections

N = int(eval(input()))
s = [list(eval(input())) for _ in range(N)]
mydict = {}
ans = 0
for i in s:
    a = str(sorted(i))
    if a in mydict:
        ans += mydict[a]
        mydict[a] += 1
    else:
        mydict.setdefault(a, 1)
print(ans)

# C - Green Bin
# https://atcoder.jp/contests/abc137/tasks/abc137_c
from collections import Counter

n = int(eval(input()))
S = []
for _ in range(n):
    s = "".join(sorted(eval(input())))
    S.append(s)
C = Counter(S)
ans = 0
for i in list(C.values()):
    ans += (i * (i - 1)) // 2
print(ans)

-import collections +# C - Green Bin +# https://atcoder.jp/contests/abc137/tasks/abc137_c +from collections import Counter -N = int(eval(input())) -s = [list(eval(input())) for _ in range(N)] -mydict = {} +n = int(eval(input())) +S = [] +for _ in range(n): +    s = "".join(sorted(eval(input()))) +    S.append(s) +C = Counter(S) -for i in s: -    a = str(sorted(i)) -    if a in mydict: -        ans += mydict[a] -        mydict[a] += 1 -    else: -        mydict.setdefault(a, 1) +for i in list(C.values()): +    ans += (i * (i - 1)) // 2