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

ps = []

for _ in range(m):

    p, s = input().split()

    ps.append((int(p), s))

was = [0]*(n+1)

total_ac = 0

total_wa = 0

for p, s in ps:

    if was[p]<0:

        continue

    if s=='AC':

        total_wa += was[p]

        total_ac += 1

        was[p] = -1

    else:

        was[p] += 1

print((total_ac, total_wa))

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()))
ps = []
for _ in range(m):
    p, s = input().split()
    ps.append((int(p), s))
was = [0] * (n + 1)
total_ac = 0
total_wa = 0
for p, s in ps:
    if was[p] < 0:
        continue
    if s == "AC":
        total_wa += was[p]
        total_ac += 1
        was[p] = -1
    else:
        was[p] += 1
print((total_ac, total_wa))

-d = {} -for i in range(m): +ps = [] +for _ in range(m): -    d.setdefault(p, []) -    d[p].append(s) -cnt = 0 -correct = 0 -for v in list(d.values()): -    if "AC" not in v: +    ps.append((int(p), s)) +was = [0] * (n + 1) +total_ac = 0 +total_wa = 0 +for p, s in ps: +    if was[p] < 0: -    correct += 1 -    cnt += v.index("AC") -print((correct, cnt)) +    if s == "AC": +        total_wa += was[p] +        total_ac += 1 +        was[p] = -1 +    else: +        was[p] += 1 +print((total_ac, total_wa))