n = int(eval(input()))

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

for i in range(n):

  s[i] = ''.join(sorted(s[i]))

t = {}

for i in range(n):

  if s[i] in t:

    t[s[i]] += 1

  else:

    t[s[i]] = 1

print((sum(t[k] * (t[k] -1) // 2 for k in t)))

import collections

N=int(eval(input()))

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

c=collections.Counter(s)

print((sum((v*(v-1))//2 for v in list(c.values()))))
n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
for i in range(n):
    s[i] = "".join(sorted(s[i]))
t = {}
for i in range(n):
    if s[i] in t:
        t[s[i]] += 1
    else:
        t[s[i]] = 1
print((sum(t[k] * (t[k] - 1) // 2 for k in t)))

import collections

N = int(eval(input()))
s = [str(sorted(eval(input()))) for i in range(N)]
c = collections.Counter(s)
print((sum((v * (v - 1)) // 2 for v in list(c.values()))))

-n = int(eval(input())) -s = [eval(input()) for _ in range(n)] -for i in range(n): -    s[i] = "".join(sorted(s[i])) -t = {} -for i in range(n): -    if s[i] in t: -        t[s[i]] += 1 -    else: -        t[s[i]] = 1 -print((sum(t[k] * (t[k] - 1) // 2 for k in t))) +import collections + +N = int(eval(input())) +s = [str(sorted(eval(input()))) for i in range(N)] +c = collections.Counter(s) +print((sum((v * (v - 1)) // 2 for v in list(c.values()))))