n, m = list(map(int, input().split()))

d = {}

for i in range(m):

    p, s = input().split()

    d.setdefault(p, [])

    d[p].append(s)



cnt = 0; correct = 0

for v in list(d.values()):

    if "AC" not in v:

        continue

    correct += 1

    cnt += v.index("AC") 



print((correct, cnt))
N, M = list(map(int, input().split()))

l = [[] for _ in range(N)]

for i in range(M):

    p, s = input().split()

    l[int(p) - 1].append(s)



correct = 0

penalty = 0

for ll in l:

    if 'AC' not in ll:

        continue



    correct += 1

    penalty += ll.index('AC')



print((correct, penalty))
n, m = list(map(int, input().split()))
d = {}
for i in range(m):
    p, s = input().split()
    d.setdefault(p, [])
    d[p].append(s)
cnt = 0
correct = 0
for v in list(d.values()):
    if "AC" not in v:
        continue
    correct += 1
    cnt += v.index("AC")
print((correct, cnt))

N, M = list(map(int, input().split()))
l = [[] for _ in range(N)]
for i in range(M):
    p, s = input().split()
    l[int(p) - 1].append(s)
correct = 0
penalty = 0
for ll in l:
    if "AC" not in ll:
        continue
    correct += 1
    penalty += ll.index("AC")
print((correct, penalty))

-n, m = list(map(int, input().split())) -d = {} -for i in range(m): +N, M = list(map(int, input().split())) +l = [[] for _ in range(N)] +for i in range(M): -    d.setdefault(p, []) -    d[p].append(s) -cnt = 0 +    l[int(p) - 1].append(s) -for v in list(d.values()): -    if "AC" not in v: +penalty = 0 +for ll in l: +    if "AC" not in ll: -    cnt += v.index("AC") -print((correct, cnt)) +    penalty += ll.index("AC") +print((correct, penalty))