N=int(eval(input()))

name=[input()[0] for _ in range(N)]

m,a,r,c,h=name.count("M"),name.count("A"),name.count("R"),name.count("C"),name.count("H")

print((m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h))
N=int(eval(input()))

n=[input()[0] for _ in range(N)]

m,a,r,c,h=n.count("M"),n.count("A"),n.count("R"),n.count("C"),n.count("H")

print((m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h))
N = int(eval(input()))
name = [input()[0] for _ in range(N)]
m, a, r, c, h = (
    name.count("M"),
    name.count("A"),
    name.count("R"),
    name.count("C"),
    name.count("H"),
)
print(
    (
        m * a * (r + c + h)
        + m * r * (c + h)
        + m * c * h
        + a * r * (c + h)
        + a * c * h
        + r * c * h
    )
)

N = int(eval(input()))
n = [input()[0] for _ in range(N)]
m, a, r, c, h = n.count("M"), n.count("A"), n.count("R"), n.count("C"), n.count("H")
print(
    (
        m * a * (r + c + h)
        + m * r * (c + h)
        + m * c * h
        + a * r * (c + h)
        + a * c * h
        + r * c * h
    )
)

-name = [input()[0] for _ in range(N)] -m, a, r, c, h = ( -    name.count("M"), -    name.count("A"), -    name.count("R"), -    name.count("C"), -    name.count("H"), -) +n = [input()[0] for _ in range(N)] +m, a, r, c, h = n.count("M"), n.count("A"), n.count("R"), n.count("C"), n.count("H")