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()))

cnt = 0

for _ in range(n):

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

  cnt += d[s]

  d[s] += 1

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()))
cnt = 0
for _ in range(n):
    s = "".join(sorted(eval(input())))
    cnt += d[s]
    d[s] += 1
print(cnt)

-    a = eval(input()) -    b = "" -    for i in sorted(a): -        b += i -    cnt += d[b] -    d[b] += 1 +    s = "".join(sorted(eval(input()))) +    cnt += d[s] +    d[s] += 1