n = int(eval(input()))

ls = {'M':0,'A':0,'R':0,'C':0,'H':0}

head = set(["M","A","R","C","H"])



for i in range(n):

    s = eval(input())

    if s[0] in head:

        ls[s[0]] += 1



head = list(head)

ans = 0

for i in range(5):

    for j in range(i+1,5):

        for k in range(j+1,5):

            ans += ls[head[i]]*ls[head[j]]*ls[head[k]]

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



check = {v:0 for v in "MARCH"}



for i in range(n):

    s = eval(input())

    if s[0] in check:

        check[s[0]] += 1

ans = 0

kijyun = "MARCH"



for a in range(5):

    for b in range(a+1,5):

        for c in range(b+1,5):

            ans += check[kijyun[a]] * check[kijyun[b]] * check[kijyun[c]]



print(ans)
n = int(eval(input()))
ls = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
head = set(["M", "A", "R", "C", "H"])
for i in range(n):
    s = eval(input())
    if s[0] in head:
        ls[s[0]] += 1
head = list(head)
ans = 0
for i in range(5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            ans += ls[head[i]] * ls[head[j]] * ls[head[k]]
print(ans)

n = int(eval(input()))
check = {v: 0 for v in "MARCH"}
for i in range(n):
    s = eval(input())
    if s[0] in check:
        check[s[0]] += 1
ans = 0
kijyun = "MARCH"
for a in range(5):
    for b in range(a + 1, 5):
        for c in range(b + 1, 5):
            ans += check[kijyun[a]] * check[kijyun[b]] * check[kijyun[c]]
print(ans)

-ls = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} -head = set(["M", "A", "R", "C", "H"]) +check = {v: 0 for v in "MARCH"} -    if s[0] in head: -        ls[s[0]] += 1 -head = list(head) +    if s[0] in check: +        check[s[0]] += 1 -for i in range(5): -    for j in range(i + 1, 5): -        for k in range(j + 1, 5): -            ans += ls[head[i]] * ls[head[j]] * ls[head[k]] +kijyun = "MARCH" +for a in range(5): +    for b in range(a + 1, 5): +        for c in range(b + 1, 5): +            ans += check[kijyun[a]] * check[kijyun[b]] * check[kijyun[c]]