n=int(eval(input()))

m=0

a=0

r=0

c=0

h=0

for i in range(n):

  s=input()[0:1]

  if s=="M":m+=1

  elif s=="A":a+=1

  elif s=="R":r+=1

  elif s=="C":c+=1

  elif s=="H":h+=1

ans=0

ans+=m*a*r

ans+=m*a*c

ans+=m*a*h

ans+=m*r*c

ans+=m*r*h

ans+=m*c*h

ans+=a*r*c

ans+=a*r*h

ans+=a*c*h

ans+=r*c*h

print(ans)
n = int(eval(input()))

from collections import Counter

c = Counter()

for _ in range(n):

    s = input()[0]

    c[s] += 1



ans = 0

ans += c["M"]*c["A"]*c["R"]

ans += c["M"]*c["A"]*c["C"]

ans += c["M"]*c["A"]*c["H"]

ans += c["M"]*c["R"]*c["C"]

ans += c["M"]*c["R"]*c["H"]

ans += c["M"]*c["C"]*c["H"]

ans += c["A"]*c["R"]*c["C"]

ans += c["A"]*c["R"]*c["H"]

ans += c["A"]*c["C"]*c["H"]

ans += c["R"]*c["C"]*c["H"]



print(ans)
n = int(eval(input()))
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(n):
    s = input()[0:1]
    if s == "M":
        m += 1
    elif s == "A":
        a += 1
    elif s == "R":
        r += 1
    elif s == "C":
        c += 1
    elif s == "H":
        h += 1
ans = 0
ans += m * a * r
ans += m * a * c
ans += m * a * h
ans += m * r * c
ans += m * r * h
ans += m * c * h
ans += a * r * c
ans += a * r * h
ans += a * c * h
ans += r * c * h
print(ans)

n = int(eval(input()))
from collections import Counter

c = Counter()
for _ in range(n):
    s = input()[0]
    c[s] += 1
ans = 0
ans += c["M"] * c["A"] * c["R"]
ans += c["M"] * c["A"] * c["C"]
ans += c["M"] * c["A"] * c["H"]
ans += c["M"] * c["R"] * c["C"]
ans += c["M"] * c["R"] * c["H"]
ans += c["M"] * c["C"] * c["H"]
ans += c["A"] * c["R"] * c["C"]
ans += c["A"] * c["R"] * c["H"]
ans += c["A"] * c["C"] * c["H"]
ans += c["R"] * c["C"] * c["H"]
print(ans)

-m = 0 -a = 0 -r = 0 -c = 0 -h = 0 -for i in range(n): -    s = input()[0:1] -    if s == "M": -        m += 1 -    elif s == "A": -        a += 1 -    elif s == "R": -        r += 1 -    elif s == "C": -        c += 1 -    elif s == "H": -        h += 1 +from collections import Counter + +c = Counter() +for _ in range(n): +    s = input()[0] +    c[s] += 1 -ans += m * a * r -ans += m * a * c -ans += m * a * h -ans += m * r * c -ans += m * r * h -ans += m * c * h -ans += a * r * c -ans += a * r * h -ans += a * c * h -ans += r * c * h +ans += c["M"] * c["A"] * c["R"] +ans += c["M"] * c["A"] * c["C"] +ans += c["M"] * c["A"] * c["H"] +ans += c["M"] * c["R"] * c["C"] +ans += c["M"] * c["R"] * c["H"] +ans += c["M"] * c["C"] * c["H"] +ans += c["A"] * c["R"] * c["C"] +ans += c["A"] * c["R"] * c["H"] +ans += c["A"] * c["C"] * c["H"] +ans += c["R"] * c["C"] * c["H"]