from collections import defaultdict

d = defaultdict(int)

n = int(eval(input()))

for _ in range(n):

  a = eval(input())

  g = [0]*26

  for i in a:

    g[ord(i)-97]+=1

  b = ''

  for i in g:

    b+=str(i)

  d[b]+=1

cnt = 0

for k,v in list(d.items()):

  if v > 1:

    cnt += v*(v-1)//2

print(cnt)
from collections import defaultdict

d = defaultdict(int)

n = int(eval(input()))

cnt = 0

for _ in range(n):

  a = eval(input())

  b = ''

  for i in sorted(a):

    b += i

  cnt += d[b]

  d[b] += 1

print(cnt)
from collections import defaultdict

d = defaultdict(int)
n = int(eval(input()))
for _ in range(n):
    a = eval(input())
    g = [0] * 26
    for i in a:
        g[ord(i) - 97] += 1
    b = ""
    for i in g:
        b += str(i)
    d[b] += 1
cnt = 0
for k, v in list(d.items()):
    if v > 1:
        cnt += v * (v - 1) // 2
print(cnt)

from collections import defaultdict

d = defaultdict(int)
n = int(eval(input()))
cnt = 0
for _ in range(n):
    a = eval(input())
    b = ""
    for i in sorted(a):
        b += i
    cnt += d[b]
    d[b] += 1
print(cnt)

+cnt = 0 -    g = [0] * 26 -    for i in a: -        g[ord(i) - 97] += 1 -    for i in g: -        b += str(i) +    for i in sorted(a): +        b += i +    cnt += d[b] -cnt = 0 -for k, v in list(d.items()): -    if v > 1: -        cnt += v * (v - 1) // 2