AtCoder Beginner Contest 151 - Welcome to AtCoder

Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).
The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.

-----Constraints-----
 - N, M, and p_i are integers.
 - 1 \leq N \leq 10^5
 - 0 \leq M \leq 10^5
 - 1 \leq p_i \leq N
 - S_i is AC or WA.

-----Input-----
Input is given from Standard Input in the following format:
N M
p_1 S_1
:
p_M S_M

-----Output-----
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.

-----Sample Input-----
2 5
1 WA
1 AC
2 WA
2 AC
2 WA

-----Sample Output-----
2 2

In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.
In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.
Thus, he has two correct answers and two penalties.

Difficulty: EASY

Starter code:

Solutions:
(n, m) = map(int, input().split())
ac = set()
(w, x) = (0, [0 for i in range(n)])
for i in range(m):
	(p, s) = input().split()
	l = int(p) - 1
	if not l in ac:
		if s == 'AC':
			ac.add(l)
			w += x[l]
		else:
			x[l] += 1
print(len(ac), w)


(N, M) = map(int, input().split())
count1 = 0
count2 = 0
lis = [0] * N
lis2 = [0] * N
for i in range(M):
	(p, S) = input().split()
	p = int(p)
	if lis[p - 1] == 0 and S == 'WA':
		lis2[p - 1] += 1
	elif lis[p - 1] == 0 and S == 'AC':
		count1 += 1
		lis[p - 1] = 1
	elif lis[p - 1] == 1 and S == 'WA':
		continue
	elif lis[p - 1] == 1 and S == 'AC':
		continue
for i in range(N):
	if lis[i] == 0:
		lis2[i] = 0
count2 = sum(lis2)
print(str(count1) + ' ' + str(count2))


(n, m) = map(int, input().split())
P = [0] * n
AC = 0
WA = 0
for i in range(m):
	(p, S) = input().split()
	p = int(p)
	if S == 'AC' and P[p - 1] != -1:
		WA += P[p - 1]
		AC += 1
		P[p - 1] = -1
	elif S == 'WA' and P[p - 1] != -1:
		P[p - 1] += 1
print(AC, WA)


(n, m) = map(int, input().split())
p = []
s = []
for i in range(m):
	(P, S) = input().split()
	p.append(int(P))
	s.append(S)
question = [0] * n
ac = 0
wa = 0
for i in range(m):
	if question[p[i] - 1] != -1:
		if s[i] == 'AC':
			ac += 1
			wa += question[p[i] - 1]
			question[p[i] - 1] = -1
		else:
			question[p[i] - 1] += 1
print(str(ac) + ' ' + str(wa))


(N, M) = map(int, input().split())
c = [0] * (N + 1)
w = [0] * (N + 1)
AC = 0
WA = 0
for i in range(M):
	(p, s) = input().split()
	p = int(p)
	if c[p] == 0 and s == 'AC':
		c[p] += 1
		AC += 1
		WA += w[p]
	elif c[p] == 0 and s == 'WA':
		w[p] += 1
print(AC, WA)


(N, M) = map(int, input().split())
AC = [0] * N
WA = [0] * N
for _ in range(M):
	(p, s) = input().split()
	if AC[int(p) - 1] == 0:
		if s == 'WA':
			WA[int(p) - 1] += 1
		elif s == 'AC':
			AC[int(p) - 1] = 1
print(sum(AC), sum((w * a for (w, a) in zip(WA, AC))))


(n, m) = map(int, input().split())
j = [0] * n
c = [0] * n
pe = 0
ac = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s[0] == 'A' and j[p] == 0:
		j[p] = 1
		ac += 1
		pe += c[p]
	elif s[0] == 'W':
		c[p] += 1
print(ac, pe)


(n, m) = map(int, input().split())
a = [list(input().split()) for _ in range(m)]
ac = [True] * n
d = [0] * n
tw = 0
ta = 0
for i in a:
	j = int(i[0]) - 1
	if ac[j]:
		if i[1] == 'WA':
			d[j] += 1
		else:
			tw += d[j]
			ta += 1
			ac[j] = False
print(ta, tw)


(n, m) = list(map(int, input().split()))
p = [input().split() for _ in range(m)]
ac = [0] * n
wa = [0] * n
for i in p:
	if i[1] == 'AC' and ac[int(i[0]) - 1] == 0:
		ac[int(i[0]) - 1] = 1
	elif i[1] == 'WA' and ac[int(i[0]) - 1] == 0:
		wa[int(i[0]) - 1] += 1
wasum = 0
for i in range(n):
	if ac[i] == 1:
		wasum += wa[i]
print(f'{sum(ac)} {wasum}')


(n, m) = map(int, input().split())
a = [0] * n
w = [0] * n
ac = 0
wc = 0
for _ in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if a[p] == 0:
		if s == 'AC':
			a[p] = 1
			ac += 1
			wc += w[p]
		else:
			w[p] += 1
print(ac, wc)


import sys
input()
d = {}
nc = np = 0
for ln in sys.stdin:
	(p, S) = ln.split()
	if p not in d:
		d[p] = [0, 0]
	if not d[p][0]:
		if S == 'AC':
			d[p][0] = 1
			nc += 1
			np += d[p][1]
		else:
			d[p][1] += 1
print(nc, np)


(N, M) = map(int, input().split())
prob = [[0, 0] for i in range(N)]
for i in range(M):
	(p, S) = input().split()
	x = int(p) - 1
	if prob[x][0] == 0 and S == 'WA':
		prob[x][1] += 1
	elif prob[x][0] == 0 and S == 'AC':
		prob[x][0] = 1
(ACs, WAs) = (0, 0)
for i in range(N):
	if prob[i][0] == 1:
		ACs += 1
		WAs += prob[i][1]
print(ACs, ' ', WAs)


from sys import stdin as s
(n, m) = map(int, s.readline().split())
l = [0] * n
wa = [0] * n
(cor, pen) = (0, 0)
for i in range(m):
	(x, y) = s.readline().split()
	x = int(x) - 1
	if y == 'AC':
		l[x] = 1
	elif not l[x]:
		wa[x] += 1
for i in range(n):
	if l[i]:
		cor += 1
		pen += wa[i]
print(cor, pen)


(N, M) = map(int, input().split())
t = [0] * (N + 1)
e = [0] * (N + 1)
for i in range(M):
	(p, s) = input().split()
	if t[int(p)] == 0 and s == 'WA':
		e[int(p)] += 1
	if t[int(p)] == 0 and s == 'AC':
		t[int(p)] = 1
for i in range(N + 1):
	if t[i] == 0:
		e[i] = 0
print(sum(t), sum(e))


(n, m) = map(int, input().split())
a = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if a[p] == 0:
		if s == 'AC':
			a[p] = 1
		else:
			b[p] += 1
for i in range(n + 1):
	if a[i] == 0:
		b[i] = 0
print(sum(a), sum(b))


(n, m) = map(int, input().split())
s = [[] for _ in [0] * n]
for _ in [0] * m:
	(p, _s) = input().split()
	s[int(p) - 1] += [_s]
ans = 0
pena = 0
for i in s:
	if 'AC' in i:
		ans += 1
		pena += i[:i.index('AC')].count('WA')
print(ans, pena)


(N, M) = map(int, input().split())
L = [0] * N
R = [0] * N
right = 0
pena = 0
for _ in range(M):
	(p, s) = input().split()
	p = int(p)
	p -= 1
	if R[p] == 0:
		if s == 'AC':
			right += 1
			R[p] = 1
			pena += L[p]
		else:
			L[p] += 1
print(right, pena)


(n, m) = map(int, input().split())
ac = [0] * (n + 1)
wa = [0] * (n + 1)
for i in range(m):
	(a, b) = map(str, input().split())
	a = int(a)
	if ac[a] == 0:
		if b == 'WA':
			wa[a] += 1
		else:
			ac[a] = 1
print(sum(ac))
ans = 0
for i in range(n + 1):
	if ac[i] == 1:
		ans += wa[i]
print(ans)


(n, m) = [int(x) for x in input().split()]
ac = [0] * n
wa = [0] * n
a = 0
b = 0
for i in range(m):
	(P, s) = input().split()
	p = int(P) - 1
	if s == 'AC':
		if ac[p] == 0:
			ac[p] = 1
			a += 1
			b += wa[p]
	elif ac[p] == 0:
		wa[p] += 1
print(a, b)


(N, M) = map(int, input().split(' '))
ac_set = set()
(wa_cnt, wa_cnt_ls) = (0, [0] * N)
for i in range(M):
	(p, s) = input().split(' ')
	idx = int(p) - 1
	if not idx in ac_set:
		if s == 'AC':
			ac_set.add(idx)
			wa_cnt += wa_cnt_ls[idx]
		else:
			wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)


(N, M) = map(int, input().split())
AC = [0] * N
WA = [0] * N
for _ in range(M):
	(p, S) = input().split()
	p = int(p) - 1
	if AC[p] == 1:
		continue
	elif S == 'AC':
		AC[p] = 1
	else:
		WA[p] += 1
Pen = [x * y for (x, y) in zip(AC, WA)]
print(sum(AC), sum(Pen))


(n, m) = map(int, input().split())
ac_count = [0] * n
wa_count = [0] * n
ac = 0
wa = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC' and ac_count[p] == 0:
		ac_count[p] = 1
		ac += 1
		wa += wa_count[p]
	elif s[0] == 'W':
		wa_count[p] += 1
print(ac, wa)


(N, M) = map(int, input().split())
AC = (N + 1) * [0]
WA = (N + 1) * [0]
wa = 0
for m in range(M):
	(p, s) = input().split()
	p = int(p)
	if AC[p] == 0 and s == 'AC':
		AC[p] = 1
		wa += WA[p]
	WA[p] += 1
print(sum(AC), wa)


(n, m) = map(int, input().split())
(ac, wa, k, l) = (0, 0, [0] * n, [0] * n)
for _ in range(m):
	(p, s) = input().split()
	if k[int(p) - 1] == 0:
		if s == 'AC':
			ac += 1
			k[int(p) - 1] = 1
			wa += l[int(p) - 1]
		else:
			l[int(p) - 1] += 1
print(ac, wa)


def i_input():
	return int(input())

def i_map():
	return map(int, input().split())

def i_list():
	return list(map(int, input().split()))

def i_row(N):
	return [int(input()) for _ in range(N)]

def i_row_list(N):
	return [list(input().split()) for _ in range(N)]
(n, m) = i_map()
ps = i_row_list(m)
ac = [0] * n
wa = [0] * n
for (p, s) in ps:
	if s == 'AC':
		ac[int(p) - 1] = 1
	if s == 'WA':
		if ac[int(p) - 1] == 0:
			wa[int(p) - 1] += 1
for i in range(n):
	if ac[i] == 0:
		wa[i] = 0
print(sum(ac), sum(wa))


(n, m) = map(int, input().split())
l = [0] * n
wcount = 0
acount = 0
for i in range(m):
	(A, B) = input().split()
	a = int(A)
	b = str(B)
	if l[a - 1] != -1 and b == 'WA':
		l[a - 1] += 1
	elif l[a - 1] != -1 and b == 'AC':
		acount += 1
		wcount += l[a - 1]
		l[a - 1] = -1
print(acount, wcount)


(N, M) = map(int, input().split())
solved = [False] * N
wal = [0] * N
ac = 0
wa = 0
for _ in range(M):
	(p, s) = input().split()
	p = int(p) - 1
	if solved[p]:
		continue
	if s == 'AC':
		solved[p] = True
		ac += 1
		wa += wal[p]
	else:
		wal[p] += 1
print(ac, wa)


(N, M) = map(int, input().split())
AC = [0] * N
WA = [0] * N
WAtimes = 0
ACtimes = 0
for i in range(M):
	(p, S) = map(str, input().split())
	p = int(p) - 1
	if 'AC' == S:
		if 0 == AC[p]:
			ACtimes += 1
			WAtimes += WA[p]
		AC[p] += 1
	if 'WA' == S:
		WA[p] += 1
print(ACtimes, WAtimes)


(N, M) = map(int, input().split())
P_S = [input().split() for _ in range(M)]
wa_cnt = [0] * N
ac = 0
wa = 0
for (p, s) in P_S:
	index = int(p) - 1
	if s == 'AC':
		if wa_cnt[index] != -1:
			wa += wa_cnt[index]
			wa_cnt[index] = -1
			ac += 1
	elif wa_cnt[index] != -1:
		wa_cnt[index] += 1
print(ac, wa)


(n, m) = map(int, input().split())
a = [0] * n
w = [0] * n
ac = 0
wa = 0
for i in range(m):
	(p, s) = map(str, input().split())
	p = int(p)
	if a[p - 1] == 0:
		if s == 'AC':
			ac += 1
			wa += w[p - 1]
			a[p - 1] = 1
		else:
			w[p - 1] += 1
print(ac, wa)


(N, M) = map(int, input().split())
ansAC = 0
ansP = 0
n = [0] * N
AC = [0] * N
for i in range(M):
	(p, s) = map(str, input().split())
	p = int(p) - 1
	if AC[p] == 1:
		continue
	if s == 'AC':
		ansP += n[p]
		ansAC += 1
		AC[p] = 1
	else:
		n[p] += 1
print(ansAC, ansP)


(N, M) = [int(i) for i in input().split(' ')]
pS = [0] * N
(ac, wa) = (0, 0)
for _ in range(M):
	(p, S) = input().split(' ')
	p = int(p) - 1
	if pS[p] != -1 and S == 'WA':
		pS[p] += 1
	if pS[p] != -1 and S == 'AC':
		ac += 1
		wa += pS[p]
		pS[p] = -1
print(ac, wa)


d = dict()
wa = ans = 0
(N, M) = map(int, input().split())
for i in range(M):
	(p, s) = input().split()
	if p not in d:
		d[p] = 0
	if d[p] >= 0 and s == 'AC':
		ans += 1
		wa += d[p]
		d[p] = -float('inf')
	else:
		d[p] += 1
print(ans, wa)


(n, m) = map(int, input().split())
acs = [0] * n
was = [0] * n
ac = 0
wa = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC' and acs[p] == 0:
		acs[p] += 1
		ac += 1
		wa += was[p]
	elif s == 'WA':
		was[p] += 1
print(ac, wa)


(n, m) = map(int, input().split())
l = [0] * n
s = set([])
for i in range(m):
	(p, q) = map(str, input().split())
	if int(p) in s:
		continue
	elif q == 'AC':
		s.add(int(p))
	else:
		l[int(p) - 1] += 1
s_l = list(s)
an = len(s_l)
c = 0
for i in range(an):
	c += l[s_l[i] - 1]
print(an, c)


(n, m) = map(int, input().split())
li = [0] * n
ans = [0, 0]
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if li[p - 1] >= 0:
		if s == 'WA':
			li[p - 1] += 1
		elif s == 'AC':
			ans[0] += 1
			ans[1] += li[p - 1]
			li[p - 1] = -1
print(*ans)


(n, m) = map(int, input().split())
A = [0] * n
W = [0] * n
w = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC' and A[p] == 0:
		A[p] = 1
		w += W[p]
	elif s == 'WA' and A[p] == 0:
		W[p] += 1
print(sum(A), w)


(n, m) = map(int, input().split())
l = [0] * (n + 1)
p = 0
for _ in range(m):
	(a, b) = list(input().split())
	if str(b) == 'AC' and l[int(a)] != -1:
		p += l[int(a)]
		l[int(a)] = -1
	elif str(b) == 'WA' and l[int(a)] != -1:
		l[int(a)] += 1
print(l.count(-1), p)


(N, M) = map(int, input().split())
AC = [0] * N
WA = [0] * N
for i in range(M):
	(p, S) = map(str, input().split())
	p = int(p)
	if AC[p - 1] == 0:
		if S == 'AC':
			AC[p - 1] += 1
		else:
			WA[p - 1] += 1
for i in range(N):
	if AC[i] == 0:
		WA[i] = 0
print(sum(AC), sum(WA))


(N, M) = map(int, input().split())
ac = [0] * N
wa = [0] * N
pena = 0
acsum = 0
for i in range(M):
	(p, S) = input().split()
	p = int(p) - 1
	if S == 'AC':
		if ac[p] == 0:
			ac[p] = 1
			pena += wa[p]
			acsum += 1
	else:
		wa[p] += 1
print(acsum, pena)


(n, m) = map(int, input().split())
ac = [0] * n
pn = [0] * n
for i in range(m):
	ps = input().split()
	p = int(ps[0]) - 1
	s = ps[1]
	if ac[p]:
		continue
	if s == 'AC':
		ac[p] = 1
	else:
		pn[p] += 1
acs = sum(ac)
pns = sum([x for (i, x) in enumerate(pn) if ac[i]])
print(acs, pns)


import sys
input()
(ac, wa) = ({*()}, {})
nc = np = 0
for ln in sys.stdin:
	(p, S) = ln.split()
	if p in ac:
		continue
	if p not in wa:
		wa[p] = 0
	if S == 'AC':
		ac.add(p)
		nc += 1
		np += wa[p]
	else:
		wa[p] += 1
print(nc, np)


(n, m) = list(map(int, input().split()))
answer = 0
penalty = 0
ans = [0] * n
pen = [0] * n
for x in range(m):
	(p, s) = input().split()
	pi = int(p) - 1
	if ans[pi] == 1:
		continue
	if s == 'AC':
		answer += 1
		ans[pi] = 1
		penalty += pen[pi]
	elif s == 'WA':
		pen[pi] += 1
print(f'{answer} {penalty}')


from collections import defaultdict

def main():
	(n, m) = map(int, input().split(' '))
	d = defaultdict(lambda : '')
	dp = defaultdict(lambda : 0)
	cnt_p = 0
	cnt_ca = 0
	for i in range(m):
		(p, s) = input().split(' ')
		if d[p] == '':
			if s == 'AC':
				d[p] = 1
				cnt_ca += 1
				cnt_p += dp[p]
			else:
				dp[p] += 1
	print(f'{cnt_ca} {cnt_p}')

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
ac = [0] * n
wa = [0] * n
for i in range(m):
	(p, s) = input().split()
	if s == 'AC' and ac[int(p) - 1] == 0:
		ac[int(p) - 1] += 1
	elif s == 'WA' and ac[int(p) - 1] == 0:
		wa[int(p) - 1] += 1
ans = 0
for (i, j) in zip(ac, wa):
	ans += i * j
print(sum(ac), ans)


(N, M) = map(int, input().split())
AC = [0] * (N + 1)
WA = [0] * (N + 1)
for i in range(0, M):
	(A, B) = map(str, input().split())
	A = int(A)
	if B == 'WA':
		if AC[A] == 0:
			WA[A] += 1
	elif AC[A] == 0:
		AC[A] = 1
Wronganswer = 0
for i in range(0, N + 1):
	Wronganswer += AC[i] * WA[i]
print(sum(AC), Wronganswer)


(n, m) = (int(x) for x in input().split())
sub = [0] * (n + 1)
ok = ng = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if sub[p] == -1:
		continue
	if s == 'WA':
		sub[p] += 1
	if s == 'AC':
		ok += 1
		ng += sub[p]
		sub[p] = -1
print(ok, ng)


(N, M) = map(int, input().split())
pS = [list(input().split()) for _ in range(M)]
b = 0
lst = [0 for _ in range(N)]
for (p, S) in pS:
	p = int(p)
	if S == 'WA' and lst[p - 1] <= 0:
		lst[p - 1] -= 1
	if S == 'AC' and lst[p - 1] <= 0:
		b += -lst[p - 1]
		lst[p - 1] = 1
print(lst.count(1), b)


(n, m) = map(int, input().split())
L = [0] * n
AC = 0
WA = 0
tmp = [0] * n
for i in range(m):
	(x, y) = input().split()
	x = int(x)
	if L[x - 1] == 0:
		if y == 'WA':
			tmp[x - 1] += 1
		else:
			AC += 1
			WA += tmp[x - 1]
			L[x - 1] = 1
print(AC, WA)


(n, m) = map(int, input().split())
li = [0] * n
ok = 0
ng = 0
pro = set()
for i in range(m):
	(p, s) = map(str, input().split())
	p = int(p)
	if s == 'WA':
		li[p - 1] += 1
	elif not p in pro:
		ok += 1
		ng += li[p - 1]
		pro.add(p)
print(ok, ng)


(n, m) = list(map(int, input().split()))
ac = 0
wa = 0
cur_n = 0
cur_wa = 0
cur_ac = False
pset = []
for i in range(m):
	(p, s) = input().split()
	pset.append((int(p), s))
pset.sort(key=lambda x: x[0])
for j in range(m):
	if cur_n != pset[j][0]:
		cur_n = pset[j][0]
		cur_ac = False
		cur_wa = 0
	if cur_ac == False:
		if pset[j][1] == 'AC':
			ac += 1
			wa += cur_wa
			cur_ac = True
		else:
			cur_wa += 1
print(f'{ac} {wa}')


(n, m) = map(int, input().split())
ac = 0
wa = 0
boac = [0] * n
bowa = [0] * n
for i in range(m):
	(p, s) = map(str, input().split())
	p = int(p) - 1
	if s == 'WA':
		bowa[p] += 1
	if s == 'AC' and boac[p] == 0:
		boac[p] = 1
		ac += 1
		wa += bowa[p]
print(ac, wa)


(n, m) = map(int, input().split())
toi = [0 for i in range(n)]
ac = 0
wa = 0
for i in range(m):
	(p, s) = map(str, input().split())
	p = int(p)
	if s == 'AC':
		if toi[p - 1] != -1:
			wa += toi[p - 1]
			ac += 1
			toi[p - 1] = -1
	elif toi[p - 1] != -1:
		toi[p - 1] += 1
print(ac, wa)


(n, m) = map(int, input().split())
a = [0] * n
ans = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if a[p] != 1:
		if s == 'WA':
			a[p] -= 1
		else:
			ans -= a[p]
			a[p] = 1
for i in range(n):
	a[i] = max(a[i], 0)
print(sum(a), ans)


(N, M) = map(int, input().split())
A = [0] * N
B = [0] * N
pen = 0
for i in range(M):
	(p, S) = input().split()
	if S == 'AC':
		A[int(p) - 1] = 1
	elif S == 'WA' and A[int(p) - 1] == 0:
		B[int(p) - 1] += 1
penalty = [A[i] * B[i] for i in range(N)]
print(sum(A), sum(penalty))


(n, m) = map(int, input().split())
li = [0] * (n + 1)
cn = [0] * (n + 1)
ac = wa = 0
for _ in range(m):
	(x, y) = input().split()
	x = int(x)
	if y == 'AC':
		if li[x] != 1:
			li[x] = 1
			ac += 1
			wa += cn[x]
	else:
		cn[x] += 1
print(ac, wa)


(N, M) = map(int, input().split())
L = [0] * N
A = 0
W = 0
tmp = [0] * N
for i in range(M):
	(x, y) = input().split()
	t = int(x)
	if L[t - 1] == 0:
		if y == 'WA':
			tmp[t - 1] += 1
		else:
			A += 1
			W += tmp[t - 1]
			L[t - 1] = 1
print(A, W)


(n, m) = list(map(int, input().split()))
wa = [0] * (n + 1)
ac = [0] * (n + 1)
for _ in range(m):
	(p, s) = input().split()
	p = int(p)
	if s == 'WA' and ac[p] == 0:
		wa[p] += 1
	elif s == 'AC':
		ac[p] = 1
for (i, ok) in enumerate(ac):
	if not ok:
		wa[i] = 0
print('{} {}'.format(sum(ac), sum(wa)))


(N, M) = map(int, input().split())
wa = [0] * N
ac = [False] * N
for i in range(M):
	(p, S) = input().split()
	p = int(p) - 1
	if S == 'AC':
		ac[p] = True
	elif not ac[p]:
		wa[p] += 1
a = 0
b = 0
for i in range(N):
	if ac[i]:
		a += 1
		b += wa[i]
print(*[a, b])


(mon, sub) = map(int, input().split())
(sei, pen) = (0, 0)
f = 0
l = [0 for i in range(mon)]
ll = [0 for i in range(mon)]
for i in range(sub):
	(n, re) = input().split()
	n = int(n)
	if l[n - 1] == 1:
		f %= 2
	elif re == 'WA':
		ll[n - 1] += 1
	else:
		l[n - 1] = 1
		sei += 1
		pen += ll[n - 1]
print(sei, pen)


import numpy as np
(n, m) = map(int, input().split())
a = np.array([list(input().split()) for i in range(m)])
b = [0] * (n + 1)
e = [0] * (n + 1)
c = 0
d = 0
for i in a:
	if b[int(i[0])] == 0:
		if i[1] == 'AC':
			c += 1
			b[int(i[0])] = 1
			d += e[int(i[0])]
		else:
			e[int(i[0])] += 1
print(c, d)


(n, m) = map(int, input().split())
AC = [0] * n
cnt = [0] * n
ans = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	s = str(s)
	if s == 'WA' and AC[p - 1] == 0:
		cnt[p - 1] += 1
	if s == 'AC' and AC[p - 1] == 0:
		AC[p - 1] = 1
		ans += cnt[p - 1]
print(sum(AC), ans)


(n, m) = [int(s) for s in input().split()]
a = [0 for _ in range(n)]
for i in range(m):
	(p, res) = input().split()
	p = int(p) - 1
	if a[p] % 2 == 0:
		a[p] += 2 if res == 'WA' else 1
print(sum([tmp % 2 for tmp in a]), sum([tmp // 2 if tmp % 2 == 1 else 0 for tmp in a]))


(n, m) = map(int, input().split())
a = [input().split() for _ in range(m)]
c = [0] * n
w = [0] * n
for i in range(m):
	if c[int(a[i][0]) - 1] == 0:
		if a[i][1] == 'AC':
			c[int(a[i][0]) - 1] += 1
		else:
			w[int(a[i][0]) - 1] += 1
	else:
		pass
for i in range(n):
	if c[i] == 0:
		w[i] = 0
	else:
		pass
print(sum(c), sum(w))


(N, M) = map(int, input().split())
ACs = [0] * (N + 1)
Ps = [0] * (N + 1)
for _ in range(M):
	(p, s) = input().split()
	p = int(p)
	if s == 'AC':
		ACs[p] = 1
	elif s == 'WA':
		if ACs[p] == 0:
			Ps[p] += 1
ans1 = sum(ACs)
ans2 = 0
for i in range(1, N + 1):
	if ACs[i] == 1:
		ans2 += Ps[i]
print(ans1, ans2)


(n, m) = map(int, input().split())
account = 0
wacount = 0
a = [0] * n
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	p -= 1
	if a[p] == -1:
		continue
	if s == 'AC':
		account += 1
		wacount += a[p]
		a[p] = -1
	else:
		a[p] += 1
print(account, wacount)


f = lambda : input().split()
(n, m) = map(int, f())
(sa, lw) = (set(), [0] * n)
for _ in range(m):
	(p, s) = f()
	if p in sa:
		continue
	if s == 'AC':
		sa.add(p)
	else:
		lw[int(p) - 1] += 1
print(len(sa), sum((lw[int(p) - 1] for p in sa)))


(N, M) = map(int, input().split())
P = [0] * N
Penalty = 0
Accepted = 0
for i in range(M):
	(p, S) = input().split()
	p = int(p)
	if S == 'AC' and P[p - 1] != -1:
		Penalty += P[p - 1]
		Accepted += 1
		P[p - 1] = -1
	elif S == 'WA' and P[p - 1] != -1:
		P[p - 1] += 1
print(Accepted, Penalty)


(N, M) = map(int, input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
	(a, b) = input().split()
	if lis[int(a) - 1] < 0:
		pass
	elif b == 'AC':
		WA += lis[int(a) - 1]
		AC += 1
		lis[int(a) - 1] = -1
	else:
		lis[int(a) - 1] += 1
print(AC, WA)


(N, M) = map(int, input().split())
A = [0] * (N + 1)
W = A.copy()
for _ in range(M):
	(P, S) = input().split()
	p = int(P)
	if S == 'AC':
		A[p] = 1
	elif A[p] == 0:
		W[p] += 1
print(sum(A), sum((a * w for (a, w) in zip(A, W))))


(n, m) = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]
c = [0] * n
for (p, s) in ps:
	if s == 'AC':
		c[int(p) - 1] = 1
d = [0] * n
wa = 0
ac = 0
for (p, s) in ps:
	if d[int(p) - 1] == 0:
		if s == 'WA':
			if c[int(p) - 1] == 1:
				wa += 1
		else:
			ac += 1
			d[int(p) - 1] = 1
print(ac, wa)


import numpy as np
(N, M) = map(int, input().split())
flag = [False] * (N + 1)
ac = 0
wa = [0] * (N + 1)
for _ in range(M):
	(p, s) = input().split()
	p = int(p)
	if flag[p] == False:
		if s == 'AC':
			flag[p] = True
		else:
			wa[p] += 1
print(sum(np.array(flag)), sum(np.array(wa) * np.array(flag)))


(n, m) = (int(i) for i in input().split())
ac = 0
pe = 0
p = [0] * (n + 1)
a = [0] * (n + 1)
for i in range(m):
	(x, y) = input().split()
	x = int(x)
	if y == 'AC':
		a[x] = 1
	elif not a[x]:
		p[x] += 1
ac = sum(a)
pe = sum((p[i] for i in range(n + 1) if a[i]))
print(ac, pe)


f = lambda : input().split()
(n, m) = map(int, f())
n += 1
(a, w) = ([0] * n, [0] * n)
for _ in range(m):
	(p, s) = f()
	p = int(p)
	if s == 'AC':
		a[p] = 1
	elif a[p] < 1:
		w[p] += 1
print(sum(a), sum((i * j for (i, j) in zip(a, w))))


(N, M) = map(int, input().split())
WA = [0] * N
AC = [0] * N
for i in range(M):
	(p, S) = map(str, input().split())
	if S == 'WA' and AC[int(p) - 1] != 1:
		WA[int(p) - 1] += 1
	elif S == 'AC':
		AC[int(p) - 1] = 1
Q = 0
for i in range(N):
	if AC[i] > 0:
		Q += WA[i]
print(sum(AC), Q)


(N, M) = map(int, input().split())
WA = [0] * (N + 1)
AC = [0] * (N + 1)
sum_WA = 0
for _ in range(M):
	(i, s) = input().split()
	i = int(i)
	if AC[i] == 0:
		if s == 'WA':
			WA[i] += 1
		elif s == 'AC':
			AC[i] = 1
			sum_WA += WA[i]
print(sum(AC), sum_WA)


(n, m) = map(int, input().split())
a = [[] for ii in range(n)]
for ii in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	a[p].append(s)
r = 0
q = 0
for ii in range(n):
	if 'AC' in a[ii]:
		r += 1
		q += a[ii].index('AC')
print(r, q)


(n, m) = map(int, input().split())
(AC, WA) = ([0] * n, [0] * n)
(ac, wa) = (0, 0)
for _ in range(m):
	(p, s) = list(map(str, input().split()))
	p = int(p) - 1
	if AC[p] == 0 and s == 'WA':
		WA[p] += 1
	elif AC[p] == 0 and s == 'AC':
		AC[p] = 1
		wa += WA[p]
		ac += 1
print(ac, wa)


(N, M) = map(int, input().split())
ac = [0] * N
wa = [0] * N
for i in range(M):
	(p, S) = input().split()
	p = int(p) - 1
	if S == 'AC':
		ac[p] = 1
	if S == 'WA' and ac[p] == 0:
		wa[p] += 1
print(sum(ac), sum((ac[i] * wa[i] for i in range(N))))


(n, m) = map(int, input().split())
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
for _ in range(m):
	(a, b) = input().split()
	a = int(a) - 1
	if b == 'AC':
		ac[a] = 1
	elif ac[a] == 0:
		wa[a] += 1
for i in range(n):
	wa[i] *= ac[i]
print(sum(ac), sum(wa))


(N, M) = map(int, input().split())
d = {'AC': 0, 'WA': 0}
b = 0
for i in range(N + 1):
	d[i] = 0
for j in range(M):
	(p, s) = input().split()
	p = int(p)
	if s == 'AC':
		if d[p] != -1:
			b = d[p]
			d[p] = -1
			d['AC'] += 1
			d['WA'] += b
			b = 0
	if s == 'WA':
		if d[p] != -1:
			d[p] += 1
print(d['AC'], end=' ')
print(d['WA'])


(N, M) = map(int, input().split())
x = [0] * N
y = [0] * N
P = []
s = []
for i in range(M):
	(p, S) = map(str, input().split())
	P.append(int(p))
	s.append(S)
for j in range(M - 1, -1, -1):
	if s[j] == 'AC':
		if x[P[j] - 1] == 0:
			x[P[j] - 1] = 1
		else:
			y[P[j] - 1] = 0
	elif s[j] == 'WA':
		if x[P[j] - 1] == 1:
			y[P[j] - 1] += 1
print(x.count(1), sum(y))


(N, M) = map(int, input().split())
(num_AC, num_WA) = (0, 0)
res = [list(input().split()) for i in range(M)]
check = ['v'] * N
WA_check = [0] * N
for (i, j) in res:
	i = int(i)
	if check[i - 1] == 'v':
		if j == 'WA':
			WA_check[i - 1] += 1
		if j == 'AC':
			num_AC += 1
			num_WA += WA_check[i - 1]
			check[i - 1] = '.'
print(num_AC, num_WA)


(N, M) = list(map(int, input().split()))
AC = [0] * N
WA = [0] * N
for i in range(M):
	(p, S) = input().split()
	p = int(p)
	if S == 'AC':
		AC[p - 1] = 1
	elif AC[p - 1] == 0:
		WA[p - 1] += 1
for i in range(N):
	if AC[i] == 0:
		WA[i] = 0
print(sum(AC), sum(WA))


(n, m) = map(int, input().split())
ac_ = [0] * n
wa_ = [0] * n
ac = 0
wa = 0
for i in range(m):
	(q, r) = input().split()
	q = int(q) - 1
	if ac_[q] == 0:
		if r == 'WA':
			wa_[q] += 1
		if r == 'AC':
			ac += 1
			wa += wa_[q]
			ac_[q] = 1
print(ac, wa)


(n, m) = map(int, input().split())
ac = [0] * n
wa = [0] * n
a = 0
w = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if ac[p] == 0 and s == 'AC':
		ac[p] += 1
		a += 1
		w += wa[p]
	elif ac[p] == 0 and s == 'WA':
		wa[p] += 1
print(a, w)


(n, m) = map(int, input().split())
r = 0
p = 0
li = [0] * n
for i in range(m):
	(a, b) = input().split()
	if li[int(a) - 1] == -1:
		pass
	elif b == 'WA':
		li[int(a) - 1] += 1
	elif b == 'AC':
		r += 1
		p += li[int(a) - 1]
		li[int(a) - 1] = -1
print(r, p)


(n, m) = map(int, input().split())
AC = [0] * (n + 1)
pen = [0] * (n + 1)
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if s == 'AC':
		AC[p] = 1
	elif AC[p] == 0:
		pen[p] += 1
print(sum(AC), sum([AC[i] * pen[i] for i in range(n + 1)]))


(N, M) = map(int, input().split())
acs = [0] * N
was = [0] * N
for i in range(M):
	(p, s) = input().split()
	if s == 'AC':
		acs[int(p) - 1] = 1
	else:
		was[int(p) - 1] += acs[int(p) - 1] != 1
was = [was[i] for i in range(N) if acs[i] == 1]
print(sum(acs), sum(was))


(n, m) = map(int, input().split())
(p, s) = ([], [])
for _ in range(m):
	(p_, s_) = input().split()
	p.append(int(p_))
	s.append(s_)
AC = [0] * n
WA = [0] * n
for i in range(m):
	if s[i] == 'WA' and AC[p[i] - 1] == 0:
		WA[p[i] - 1] += 1
	elif s[i] == 'AC' and AC[p[i] - 1] == 0:
		AC[p[i] - 1] += 1
for i in range(m):
	if AC[p[i] - 1] == 0:
		WA[p[i] - 1] = 0
print(sum(AC), sum(WA))


import sys
input = sys.stdin.readline
import numpy as np

def main():
	(n, m) = map(int, input().split())
	wa_answers = np.zeros(n + 1, dtype=int)
	ac_flag = np.zeros(n + 1, dtype=int)
	for i in range(m):
		(no, result) = input().split()
		no = int(no)
		if result == 'AC' and ac_flag[no] == 0:
			ac_flag[no] = 1
		if result == 'WA' and ac_flag[no] == 0:
			wa_answers[no] += 1
	print(sum(ac_flag), sum(ac_flag * wa_answers))

def __starting_point():
	main()
__starting_point()


[n, m] = [int(x) for x in input().split()]
ac = [0] * (n + 1)
wa = [0] * (n + 1)
cnt_ac = 0
cnt_wa = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if s == 'AC':
		if ac[p] == 0:
			cnt_ac += 1
			cnt_wa += wa[p]
			ac[p] = 1
	else:
		wa[p] += 1
print(int(cnt_ac), int(cnt_wa))


(n, m) = map(int, input().split())
d = [0] * (n + 1)
ac = 0
wa = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if d[p] == -1:
		continue
	elif s == 'AC':
		ac += 1
		wa += d[p]
		d[p] = -1
	else:
		d[p] += 1
print(ac, wa)


AC = 0
WA = 0
(N, M) = map(int, input().split())
A = [0] * N
for i in range(M):
	(p, S) = input().split()
	q = int(p) - 1
	if S == 'AC' and A[q] != -1:
		AC += 1
		WA += A[q]
		A[q] = -1
	elif S == 'WA' and A[q] != -1:
		A[q] += 1
print(AC, WA)


(n, m) = map(int, input().split())
ac = [0] * (n + 1)
wa = 0
for i in range(m):
	(p, c) = input().split()
	if c == 'WA' and ac[int(p)] != 1:
		ac[int(p)] -= 1
	elif c == 'AC' and ac[int(p)] != 1:
		wa += abs(ac[int(p)])
		ac[int(p)] = 1
print(ac.count(1), wa)


(n, m) = map(int, input().split())
a = 0
p = 0
L = [0 for _ in range(n)]
for _ in range(m):
	(num, s) = input().split()
	num = int(num) - 1
	if not L[num] == -1:
		if s == 'AC':
			a += 1
			p += L[num]
			L[num] = -1
		else:
			L[num] += 1
print(a, p)


R = lambda : input().split()
(n, m) = map(int, R())
a = [False] * n
b = [0] * n
for _ in range(m):
	(p, s) = R()
	p = int(p) - 1
	if s == 'AC':
		a[p] = True
	elif not a[p]:
		b[p] += 1
b = [y for (x, y) in zip(a, b) if x]
print(len(b), sum(b))


(n, m) = map(int, input().split())
l = [[] for _ in range(n)]
(ac, wa) = (0, 0)
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if s == 'AC':
		if s not in l[p - 1]:
			l[p - 1].append(s)
			ac += 1
			wa += l[p - 1].count('WA')
	else:
		l[p - 1].append(s)
print(ac, wa)


import sys

def readint():
	return int(sys.stdin.readline())

def readints():
	return tuple(map(int, sys.stdin.readline().split()))

def readintslist(n):
	return [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)]

def main():
	(n, m) = readints()
	frag = [False] * (n + 1)
	penalties = [0] * (n + 1)
	for _ in range(m):
		(p, s) = input().split()
		p = int(p)
		if frag[p]:
			continue
		if s == 'AC':
			frag[p] = True
		else:
			penalties[p] += 1
	print(sum(frag), sum([penalties[i] for i in range(n + 1) if frag[i]]))

def __starting_point():
	main()
__starting_point()


(N, M) = map(int, input().split())
ac = set()
pena = 0
walen = [0] * N
for i in range(M):
	(p, S) = map(str, input().split())
	p = int(p) - 1
	if p in ac:
		continue
	elif S == 'AC':
		ac.add(p)
		pena += walen[p]
	else:
		walen[p] += 1
print(len(ac), pena)


(N, M) = map(int, input().split())
AC = [0] * (N + 1)
WA = [0] * (N + 1)
ans = 0
for _ in range(M):
	(p, s) = input().split()
	p = int(p)
	if AC[p] == 0:
		if s == 'AC':
			AC[p] = 1
			ans += WA[p]
		else:
			WA[p] += 1
print(sum(AC), ans)


(a, b) = map(int, input().split())
c = [0] * a
d = [0] * a
e = 0
for i in range(b):
	(p, s) = input().split()
	p = int(p) - 1
	if c[p] == 0 and s == 'AC':
		c[p] = 1
		e += d[p]
	d[p] += 1
print(sum(c), e)


(n, m) = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]
wa = [0] * n
w = 0
ac = 0
d = [0] * n
for (p, s) in ps:
	if s == 'WA':
		if d[int(p) - 1] == 0:
			wa[int(p) - 1] += 1
	elif d[int(p) - 1] == 0:
		ac += 1
		d[int(p) - 1] = 1
		w += wa[int(p) - 1]
print(ac, w)


(n, m) = map(int, input().split())
acs = [0] * n
was = [0] * n
WA = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if acs[p - 1] == 0:
		if s == 'AC':
			acs[p - 1] = 1
			WA += was[p - 1]
		else:
			was[p - 1] += 1
print(sum(acs), WA)


(n, m) = map(int, input().split())
ac = [0] * (n + 1)
wa = [0] * (n + 1)
for i in range(m):
	(p, s) = input().split()
	if ac[int(p)] != 1:
		if s == 'WA':
			wa[int(p)] = wa[int(p)] + 1
		else:
			ac[int(p)] = 1
for i in range(n + 1):
	if ac[i] == 0:
		wa[i] = 0
print(sum(ac), sum(wa))


(n, m) = map(int, input().split())
ok = [0] * (n + 1)
pe = [0] * (n + 1)
for _ in range(m):
	(q, s) = input().split()
	q = int(q)
	if s == 'WA' and ok[q] == 0:
		pe[q] += 1
	else:
		ok[q] = 1
for i in range(n + 1):
	if ok[i] == 0:
		pe[i] = 0
print(sum(ok), sum(pe))


(n, m) = map(int, input().split())
p = [0] * n
q = [False] * n
for _ in range(m):
	(v, s) = input().split()
	v = int(v) - 1
	if q[v]:
		continue
	if s == 'AC':
		q[v] = True
	else:
		p[v] += 1
print(sum(q), sum((p[i] for i in range(n) if q[i])))


(N, M) = map(int, input().split())
P = []
S = []
AC = [0] * (N + 1)
WA = [0] * (N + 1)
ac = 0
wa = 0
for i in range(M):
	(p, s) = input().split()
	P.append(int(p))
	S.append(s)
for i in range(M):
	if S[i] == 'WA' and AC[P[i]] == 0:
		WA[P[i]] += 1
	if S[i] == 'AC':
		AC[P[i]] += 1
for i in range(1, N + 1):
	if AC[i] >= 1:
		ac += 1
		wa += WA[i]
print(ac, wa)


(n, m) = map(int, input().split())
(acf, waf) = ([0] * n, [0] * n)
(ac, wa) = (0, 0)
for i in range(m):
	(x, y) = input().split()
	x = int(x)
	if y == 'AC':
		if acf[x - 1] == 0:
			ac += 1
			wa += waf[x - 1]
			acf[x - 1] += 1
	else:
		waf[x - 1] += 1
print(ac, wa)


(N, M) = map(int, input().split())
res = [0] * N
(ac, wa) = (0, 0)
for i in range(M):
	(p, s) = input().split()
	p = int(p) - 1
	if res[p] == -1:
		continue
	elif s == 'AC':
		wa += res[p]
		res[p] = -1
		ac += 1
	else:
		res[p] += 1
print(ac, wa)


(N, M) = map(int, input().split())
P = [0] * (N + 1)
S = [0] * (N + 1)
for i in range(M):
	(x, p) = input().split()
	s = int(x)
	if P[s] == 0:
		if p == 'AC':
			P[s] = 1
		else:
			S[s] += 1
A = sum([S[i] for i in range(N + 1) if P[i] == 1])
print(P.count(1), A)


(N, M) = map(int, input().split())
S = [0] * N
Q = [0] * N
for i in range(M):
	(p, s) = map(str, input().split())
	p = int(p)
	if s == 'AC':
		S[p - 1] = 1
	elif s == 'WA' and S[p - 1] == 0:
		Q[p - 1] += 1
	else:
		pass
Q_com = [x * y for (x, y) in zip(S, Q)]
print(S.count(1), sum(Q_com))


(N, M) = map(int, input().split())
(ac, wa) = (0, 0)
task = [0] * N
for m in range(M):
	(p, S) = input().split()
	p = int(p) - 1
	if task[p] != -1 and S == 'WA':
		task[p] += 1
	elif task[p] != -1 and S == 'AC':
		ac += 1
		wa += task[p]
		task[p] = -1
print(ac, wa)


(n, m) = map(int, input().split())
A = [0] * n
W = [0] * n
wa = 0
ac = 0
for _ in range(m):
	(p, s) = input().split()
	if s == 'AC':
		A[int(p) - 1] = 1
	if s == 'WA' and A[int(p) - 1] != 1:
		W[int(p) - 1] += 1
for i in range(n):
	if A[int(i)] == 0:
		W[int(i)] = 0
print(sum(A), sum(W))


(n, m) = map(int, input().split())
A = [0] * n
(ac, wa) = (0, 0)
for i in range(m):
	(p, s) = map(str, input().split())
	p = int(p)
	if s == 'AC' and A[p - 1] != -1:
		ac += 1
		wa += A[p - 1]
		A[p - 1] = -1
	elif s == 'WA' and A[p - 1] != -1:
		A[p - 1] += 1
print(ac, wa)


(n, m) = map(int, input().split())
(ac, wa) = (0, 0)
number = [0] * n
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if number[p] != -1:
		if s == 'WA':
			number[p] += 1
		elif s == 'AC':
			ac += 1
			wa += number[p]
			number[p] = -1
print(ac, wa)


(n, m) = map(int, input().split())
ps = [list(map(str, input().split())) for _ in range(m)]
str_l = ['WA'] * n
int_l = [0] * n
num = 0
ac = 0
for (pp, s) in ps:
	p = int(pp) - 1
	if s == 'AC':
		str_l[p] = 'AC'
	elif str_l[p] != 'AC':
		int_l[p] += 1
for i in range(n):
	if str_l[i] == 'AC':
		num += int_l[i]
		ac += 1
print(ac, num)


(n, m) = map(int, input().split())
x = [list(input().split()) for i in range(m)]
a = 0
p = 0
x.sort(key=lambda x: x[0])
t = 'a'
for i in range(m):
	if t != x[i][0]:
		w = 0
		t = x[i][0]
		f = 1
	if f:
		if x[i][1] == 'AC':
			a += 1
			p += w
			f = 0
		else:
			w += 1
print(a, p)


(N, M) = map(int, input().split())
AC = [0] * N
WA = [0] * N
wa = 0
for i in range(M):
	(j, res) = input().split()
	j = int(j) - 1
	if AC[j] == 0 and res == 'AC':
		AC[j] = 1
		wa += WA[j]
	WA[j] += 1
print(sum(AC), wa)


(n, m) = map(int, input().split())
pp = [0] * n
res = 0
qq = [True] * n
for i in range(m):
	(i, j) = input().split()
	i = int(i)
	i -= 1
	if j == 'AC':
		if qq[i]:
			qq[i] = False
			res += pp[i]
	else:
		pp[i] += 1
print(qq.count(False), res)


(N, M) = map(int, input().split())
ac = [0] + [0] * N
wa = [0] + [0] * N
for _ in range(M):
	(number, ans) = input().split()
	number = int(number)
	if ans == 'AC':
		ac[number] = 1
	elif ac[number] == 0:
		wa[number] += 1
print(sum(ac), sum((c for (i, c) in enumerate(wa) if ac[i] == 1)))


(N, M) = map(int, input().split())
p_S = [input().split() for _ in range(M)]
AC = [False] * N
WA = [0] * N
for i in range(M):
	num = int(p_S[i][0]) - 1
	if AC[num] == 0 and p_S[i][1] == 'WA':
		WA[num] += 1
	elif AC[num] == 0 and p_S[i][1] == 'AC':
		AC[num] = True
	else:
		continue
s = 0
for i in range(N):
	if AC[i]:
		s += WA[i]
print(sum(AC), s)


(N, M) = map(int, input().split())
P = [0] * N
wa = 0
for _ in range(M):
	(p, s) = input().split()
	index = int(p) - 1
	if s == 'WA' and P[index] != -1:
		P[index] += 1
	elif P[index] > -1:
		wa += P[index]
		P[index] = -1
print(P.count(-1), wa)


(N, M) = map(int, input().split())
AC = [0] * N
WA1 = [0] * N
WA2 = [0] * N
for i in range(M):
	(p, s) = input().split()
	if s == 'AC':
		if AC[int(p) - 1] == 0:
			AC[int(p) - 1] = 1
			WA2[int(p) - 1] = WA1[int(p) - 1]
	elif AC[int(p) - 1] == 0:
		WA1[int(p) - 1] += 1
print(str(AC.count(1)) + ' ' + str(sum(WA2)))


(N, M) = map(int, input().split())
AC = N * [0]
WA = N * [0]
for m in range(M):
	(P, S) = input().split()
	P = int(P) - 1
	if AC[P] == 1:
		continue
	if S == 'WA':
		WA[P] += 1
	else:
		AC[P] = 1
wa = 0
for (a, w) in zip(AC, WA):
	wa += w * a
print(sum(AC), wa)


(n, m) = map(int, input().split())
r = [False] * n
q = [0] * n
res = 0
for _ in [0] * m:
	(p, s) = map(str, input().split())
	p = int(p) - 1
	if s == 'AC':
		if not r[p]:
			r[p] = True
			res += q[p]
	else:
		q[p] += 1
print(sum(r), res)


(N, M) = map(int, input().split())
S = [0] * N
(r, w) = (0, 0)
for i in range(M):
	(p, s) = input().split()
	if S[int(p) - 1] >= 0:
		if s == 'AC':
			r += 1
			w += S[int(p) - 1]
			S[int(p) - 1] = -1
		else:
			S[int(p) - 1] = S[int(p) - 1] + 1
print(r, w)


(n, m) = map(int, input().split())
l = [[0 for i in range(2)] for j in range(n + 1)]
(wa, ac) = (0, 0)
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if s == 'WA' and l[p][1] == 0:
		l[p][0] += 1
	elif s == 'AC' and l[p][1] == 0:
		l[p][1] += 1
		ac += 1
		wa += l[p][0]
print(ac, wa)


(n, m) = map(int, input().split())
wa = [0] * n
ac = [False] * n
for _ in range(m):
	(p, s) = input().split()
	p = int(p)
	if ac[p - 1]:
		continue
	elif s == 'WA':
		wa[p - 1] += 1
	else:
		ac[p - 1] = True
print(ac.count(True), end=' ')
w = 0
for i in range(n):
	if ac[i]:
		w += wa[i]
print(w)


import sys
input = sys.stdin.readline
a = b = 0
(n, m) = map(int, input().split())
ans = [0] * n
for i in range(m):
	(p, s) = input().rstrip().split()
	p = int(p)
	if ans[p - 1] <= 0:
		if s == 'AC':
			a += 1
			b += -ans[p - 1]
			ans[p - 1] = 1
		else:
			ans[p - 1] -= 1
print(a, b)


(n, m) = map(int, input().split())
l1 = [0] * n
l2 = [0] * n
for i in range(m):
	(p, s) = map(str, input().split())
	p = int(p)
	if s == 'AC':
		l2[p - 1] += 1
	elif l2[p - 1] == 0:
		l1[p - 1] += 1
cntac = 0
cntwa = 0
for i in range(n):
	if l2[i] != 0:
		cntac += 1
		cntwa += l1[i]
print(cntac, cntwa)


(N, M) = map(int, input().split())
ACL = [0] * N
PL = [0] * N
AC = 0
P = 0
for i in range(M):
	(p, S) = input().split()
	p = int(p)
	p -= 1
	if S == 'AC':
		if ACL[p] == 0:
			AC += 1
			P += PL[p]
			ACL[p] = 1
	else:
		PL[p] += 1
print(AC, P)


(N, M) = [int(i) for i in input().split()]
(AC, WA) = ([False] * N, [0] * N)
panel = 0
for i in range(M):
	(p, s) = input().split()
	p = int(p) - 1
	if AC[p]:
		continue
	if s == 'WA':
		WA[p] += 1
	else:
		AC[p] = True
		panel += WA[p]
ac = sum(AC)
print(ac, panel)


(N, M) = map(int, input().split())
ac = [0] * N
wa = [0] * N
for _ in range(M):
	(p, S) = input().split()
	p = int(p) - 1
	if S == 'AC':
		ac[p] = 1
	elif ac[p] == 0:
		wa[p] += 1
a = 0
b = 0
for i in range(N):
	if ac[i]:
		a += 1
		b += wa[i]
print(*[a, b])


(n, m) = map(int, input().split())
ans = [0] * n
pen = [0] * n
res_pen = 0
for i in range(m):
	(p, s) = list(input().split())
	if ans[int(p) - 1] != 1:
		if s == 'AC':
			ans[int(p) - 1] = 1
			res_pen += pen[int(p) - 1]
		else:
			pen[int(p) - 1] += 1
print(str(sum(ans)) + ' ' + str(res_pen))


(n, m) = map(int, input().split())
l = [0] * n
w = 0
c = 0
ac = set()
for i in range(m):
	(p, s) = map(str, input().split())
	p = int(p)
	if s == 'WA':
		l[p - 1] += 1
	elif p not in ac:
		c += 1
		w += l[p - 1]
		ac.add(p)
print(c, w)


(N, M) = map(int, input().split())
AC = [0] * N
WA = [0] * N
ac = 0
wa = 0
for i in range(M):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC' and AC[p] == 0:
		AC[p] = 1
		ac += 1
		wa += WA[p]
	elif s == 'WA':
		WA[p] += 1
print(ac, wa)


(n, m) = map(int, input().split())
(p, s) = ([], [])
for _ in range(m):
	(a, b) = map(str, input().split())
	p.append(a)
	s.append(b)
p = list(map(int, p))
checker = [0] * n
penalty = [0] * n
ans = 0
for (i, j) in enumerate(s):
	if j == 'AC' and checker[p[i] - 1] == 0:
		checker[p[i] - 1] = 1
	elif j == 'WA' and checker[p[i] - 1] == 0:
		penalty[p[i] - 1] += 1
for (k, l) in enumerate(checker):
	if l:
		ans += penalty[k]
print(sum(checker), ans)


(n, m) = map(int, input().split())
answers = []
for _ in range(m):
	(num, res) = input().split()
	num = int(num)
	answers.append([num, res])
AC_cnt = 0
WA_cnt = 0
AC_problems = [0] * n
WA_problems = [0] * n
for answer in answers:
	if answer[1] == 'WA' and AC_problems[answer[0] - 1] != 1:
		WA_problems[answer[0] - 1] += 1
	elif AC_problems[answer[0] - 1] == 0:
		AC_problems[answer[0] - 1] += 1
	else:
		continue
for i in range(len(AC_problems)):
	AC_cnt += AC_problems[i]
	if AC_problems[i] == 1:
		WA_cnt += WA_problems[i]
print(AC_cnt, WA_cnt)


(n, m) = map(int, input().split())
L = [0] * n
W = [0] * n
cnt = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if L[p - 1] == 0:
		if s == 'AC':
			L[p - 1] = 1
		else:
			W[p - 1] += 1
for i in range(n):
	if L[i] == 1:
		cnt += W[i]
print(sum(L), cnt)


(n, m) = map(int, input().split())
ls = [0 for _ in range(n + 1)]
ans = 0
pen = 0
for _ in range(m):
	(p, s) = input().split()
	p = int(p)
	if ls[p] == None:
		pass
	elif s == 'WA':
		ls[p] += 1
	else:
		pen += ls[p]
		ls[p] = None
		ans += 1
print(ans, pen)


(n, m) = map(int, input().split())
sgn = [0 for i in range(n)]
penal = [0 for i in range(n)]
pp = 0
for i in range(m):
	(p, s) = map(str, input().split())
	p = int(p) - 1
	if s == 'AC':
		if sgn[p] == 0:
			pp += penal[p]
		sgn[p] = 1
	else:
		penal[p] += 1
print(sum(sgn), pp)


from collections import *
r = set()
c = defaultdict(int)
(n, m) = map(int, input().split())
for _ in range(m):
	l = input().split()
	i = int(l[0])
	if l[1] == 'AC':
		r.add(i)
	elif i not in r:
		c[i] += 1
print(len(r), sum((v for (k, v) in c.items() if k in r)))


(N, M) = map(int, input().split())
ac = [0] * N
wa = [0] * N
for i in range(M):
	(p, s) = input().split()
	p = int(p) - 1
	if not ac[p]:
		if s > 'AC':
			wa[p] += 1
		else:
			ac[p] = 1
a = 0
w = 0
for i in range(N):
	if ac[i]:
		a += 1
		w += wa[i]
print(a, w)


(n, m) = map(int, input().split())
(w, l) = (0, [0] * n)
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC':
		w += l[p] * (l[p] >= 0)
		l[p] = -1
	else:
		l[p] += l[p] >= 0
print(l.count(-1), w)


(n, m) = map(int, input().split())
l = [0] * n
ac = [False] * n
cnt = 0
acnt = 0
for i in range(m):
	(a, b) = input().split()
	a = int(a)
	if ac[a - 1]:
		continue
	if b == 'AC':
		cnt += l[a - 1]
		acnt += 1
		ac[a - 1] = True
	if b == 'WA':
		l[a - 1] += 1
print(acnt, cnt)


(n, m) = map(int, input().split())
l = []
for _ in range(n):
	l.append(0)
wa = 0
for i in range(m):
	(p, s) = map(str, input().split())
	if l[int(p) - 1] == -1:
		continue
	elif s == 'AC':
		wa += l[int(p) - 1]
		l[int(p) - 1] = -1
	else:
		l[int(p) - 1] += 1
print(l.count(-1), wa)


(n, m) = map(int, input().split())
lst = [[i for i in input().split()] for j in range(m)]
ac = {}
wa = {}
visited = []
for d in lst:
	if d[0] in ac.keys():
		continue
	if d[1] == 'AC':
		if d[0] not in ac.keys():
			ac[d[0]] = 1
	elif d[0] in wa.keys():
		wa[d[0]] += 1
	else:
		wa[d[0]] = 1
ac_count = 0
wa_count = 0
for d in ac.keys():
	ac_count += 1
	if d in wa.keys():
		wa_count += int(wa[d])
print(ac_count, wa_count)


(N, M) = map(int, input().split())
ans = [0] * N
ac = 0
p = 0
for m in range(M):
	(a, b) = map(str, input().split())
	a = int(a) - 1
	if ans[a] != -1 and b == 'WA':
		ans[a] += 1
	if ans[a] != -1 and b == 'AC':
		ac += 1
		p += ans[a]
		ans[a] = -1
print(ac, p)


(n, m) = map(int, input().split())
x = [0] * n
y = [0] * n
for i in range(m):
	(P, s) = input().split()
	p = int(P)
	if x[p - 1] == 0:
		if s == 'WA':
			y[p - 1] += 1
		if s == 'AC':
			x[p - 1] += 1
sx = 0
sy = 0
for i in range(n):
	sx += x[i]
	if x[i] == 1:
		sy += y[i]
print(str(sx), str(sy))


(n, m) = map(int, input().split())
a = [0] * n
b = [0] * n
ac = wa = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s[0] == 'A' and a[p] == 0:
		a[p] = 1
		ac += 1
		wa += b[p]
	elif s[0] == 'W':
		b[p] += 1
print(ac, wa)


(n, m) = map(int, input().split())
sac = set()
lwa = [0] * n
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if p in sac:
		continue
	elif s == 'AC':
		sac.add(p)
	else:
		lwa[p] += 1
print(len(sac), sum((lwa[p] for p in sac)))


(n, m) = map(int, input().split())
f = [0] * n
ac = 0
w = [0] * n
wa = 0
for i in range(m):
	(p, q) = map(str, input().split())
	p = int(p) - 1
	if f[p] == 0:
		if q == 'AC':
			f[p] = 1
			ac += 1
			wa += w[p]
		else:
			w[p] += 1
print(ac, wa)


(n, m) = map(int, input().split())
di = [[] for _ in range(n)]
ac = 0
wa = 0
for i in range(m):
	(a, b) = map(str, input().split())
	di[int(a) - 1].append(b)
for j in range(n):
	if 'AC' in di[j]:
		wa += di[j].index('AC')
		ac += 1
print(ac, wa)


(n, m) = map(int, input().split())
ac = [0] * n
wa = [0] * n
x = 0
y = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if s == 'WA' and ac[p - 1] == 0:
		wa[p - 1] += 1
	elif s == 'AC' and ac[p - 1] == 0:
		ac[p - 1] = 1
		y += wa[p - 1]
		x += 1
print(x, y)


(n, m) = map(int, input().split())
d = {}
for _ in range(m):
	(p, s) = input().split()
	try:
		d[int(p)].append(s)
	except:
		d[int(p)] = [s]
T = 0
pe = 0
for key in d:
	if 'AC' in d[key]:
		T += 1
		pe += d[key].index('AC')
print(T, pe)


from collections import defaultdict as dc
(n, m) = [int(i) for i in input().split()]
cq_dic = {}
wa_dic = dc(int)
for _ in range(m):
	(p, w) = input().split()
	if w == 'AC':
		cq_dic[p] = 1
	elif not p in cq_dic and w == 'WA':
		wa_dic[p] += 1
ans = sum([wa_dic[k] for k in cq_dic])
print(len(cq_dic), ans)


(N, M) = map(int, input().split())
import sys
S = sys.stdin.readlines()
A = set()
WA = [0] * N
B = [0] * N
for i in range(M):
	(p, t) = S[i].split()
	p = int(p)
	if p not in A and t == 'AC':
		A.add(p)
		B[p - 1] += WA[p - 1]
	elif p not in A and t == 'WA':
		WA[p - 1] += 1
print(len(A))
print(sum(B))


(N, M) = map(int, input().split(' '))
AC = [0] * N
WA = [0] * N
for i in range(M):
	(p, s) = input().split(' ')
	p = int(p)
	if s == 'AC':
		AC[p - 1] = 1
	elif not AC[p - 1]:
		WA[p - 1] += 1
print(sum(AC), sum([i if j == 1 else 0 for (i, j) in zip(WA, AC)]))


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

def LI():
	return list(map(int, input().split()))

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	AC = defaultdict(int)
	WA = defaultdict(int)
	(N, M) = MI()
	wa = 0
	for i in range(M):
		(p, S) = input().split()
		if AC[p] == 0:
			if S == 'WA':
				WA[p] += 1
			else:
				AC[p] = 1
				wa += WA[p]
	ac = sum(AC.values())
	print(ac, wa)

def __starting_point():
	main()
__starting_point()


(N, M) = map(int, input().split())
fin = set()
AC = 0
WA = 0
WAL = [0] * N
for i in range(M):
	(p, s) = input().split()
	p = int(p)
	if not p in fin:
		if s == 'AC':
			AC += 1
			fin.add(p)
		if s == 'WA':
			WAL[p - 1] += 1
for k in fin:
	WA += WAL[k - 1]
print(AC, WA)


(n, m) = map(int, input().split())
(wa, ac) = ([0] * n, [0] * n)
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	if s == 'AC':
		ac[p - 1] = 1
	elif ac[p - 1] == 0:
		wa[p - 1] += 1
wac = 0
for i in range(n):
	wac += wa[i] * ac[i]
print(sum(ac), wac)


(N, M) = map(int, input().split(' '))
ac_set = set()
wa_cnt_list = [0] * N
(ac_cnt, wa_cnt) = (0, 0)
for i in range(M):
	(num, res) = input().split(' ')
	num = int(num) - 1
	if num not in ac_set:
		if res == 'AC':
			ac_cnt += 1
			wa_cnt += wa_cnt_list[num]
			ac_set.add(num)
		else:
			wa_cnt_list[num] += 1
print(ac_cnt, wa_cnt)


(n, m) = map(int, input().split())
ans = [0, 0]
ac = [0 for _ in range(n)]
for _ in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if ac[p] == -1:
		continue
	elif s == 'AC':
		ans[0] += 1
		ans[1] += ac[p]
		ac[p] = -1
	else:
		ac[p] += 1
print(*ans)


(n, m) = 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 d.values():
	if 'AC' not in v:
		continue
	correct += 1
	cnt += v.index('AC')
print(correct, cnt)


(N, M) = map(int, input().split())
ac = [0] * N
pn = [0] * N
for i in range(M):
	(p, s) = input().split()
	p = int(p)
	if ac[p - 1] == 0:
		if s == 'AC':
			ac[p - 1] = 1
		else:
			pn[p - 1] += 1
pna = 0
for i in range(N):
	if ac[i] == 1:
		pna += pn[i]
print(sum(ac), pna)


(n, m) = map(int, input().split())
s = [[] for i in range(n)]
for i in range(m):
	(p, S) = input().split()
	s[int(p) - 1] += [S]
print(sum(('AC' in si for si in s)), end=' ')
print(sum((si[:si.index('AC')].count('WA') if 'AC' in si else 0 for si in s)))


(N, M) = map(int, input().split())
if M == 0:
	print('0 0')
else:
	ac = 0
	pe = 0
	ch = [0] * N
	Ch = [0] * N
	for i in range(M):
		(a, b) = input().split()
		a = int(a) - 1
		if ch[a] == 1:
			continue
		elif b == 'WA':
			Ch[a] += 1
		else:
			ch[a] = 1
			ac += 1
			pe += Ch[a]
	print(ac, pe)


(n1, m1) = map(int, input().split())
dic = [0 for i in range(n1)]
se = set()
for i in range(m1):
	(n, m) = input().split()
	if n not in se and m == 'WA':
		dic[int(n) - 1] += 1
	else:
		se.add(n)
print(len(se), sum([dic[int(i) - 1] for i in se]))


(n, m) = map(int, input().split())
p = [0]
p *= n
ac = set()
wa = 0
for i in range(m):
	(pi, si) = input().split()
	pi = int(pi)
	if si == 'AC' and (not pi in ac):
		ac.add(pi)
		wa += p[pi - 1]
	else:
		p[pi - 1] += 1
ans = len(ac)
print(ans, wa, end=' ')


(N, M) = map(int, input().split())
a = [0] * (N + 1)
w = [0] * (N + 1)
for _ in range(M):
	(p, s) = input().split()
	p = int(p)
	if s == 'AC':
		a[p] = 1
	elif a[p] == 0:
		w[p] += 1
a2 = 0
w2 = 0
for n in range(N + 1):
	if a[n] == 1:
		a2 += a[n]
		w2 += w[n]
print(a2, w2)


(n, m) = map(int, input().split())
s = [0] * n
t = [0] * n
for i in range(m):
	(a, b) = map(str, input().split())
	(a,)
	a = int(a) - 1
	if not s[a]:
		if b == 'WA':
			t[a] += 1
		else:
			s[a] = 1
print(sum(s), sum((t[i] for i in range(n) if s[i])))


(n, m) = map(int, input().split())
ac = [0] * (n + 1)
wa = [0] * (n + 1)
for _ in range(m):
	(i, j) = input().split()
	i = int(i)
	if j == 'AC':
		ac[i] = 1
	elif ac[i] == 0 and j == 'WA':
		wa[i] += 1
print(sum(ac), sum((wa[i] for i in range(n + 1) if ac[i] == 1)))


from collections import defaultdict
(n, m) = list(map(int, input().split()))
wa = defaultdict(int)
ac = set()
for _ in range(m):
	(p, s) = input().split()
	if s == 'AC':
		ac.add(p)
	if p not in ac and s == 'WA':
		wa[p] += 1
print(len(ac), sum([wa[i] for i in ac]))


(n, m) = map(int, input().split())
ac = [0] * (n + 1)
wa = [0] * (n + 1)
for _ in range(m):
	(p, s) = tuple(input().split())
	p = int(p)
	if ac[p] == 1:
		continue
	if s == 'WA':
		wa[p] += 1
	else:
		ac[p] = 1
pena = 0
for (a, w) in zip(ac, wa):
	pena += a * w
print(sum(ac), pena)


(n, m) = map(int, input().split())
done = [0] * (n + 1)
wa = [0] * (n + 1)
pen = 0
for i in range(m):
	(p, q) = input().split()
	p = int(p)
	if q == 'WA':
		if done[p] == 0:
			wa[p] += 1
	elif done[p] == 0:
		done[p] = 1
		pen += wa[p]
print(sum(done), pen)


(n, m) = map(int, input().split())
a = [0] * n
(AC, WA) = (0, 0)
for i in range(m):
	(x, y) = input().split()
	x = int(x)
	if a[x - 1] != -1 and y == 'WA':
		a[x - 1] += 1
	if a[x - 1] != -1 and y == 'AC':
		WA += a[x - 1]
		AC += 1
		a[x - 1] = -1
print(AC, WA)


(n, m) = map(int, input().split())
acl = ['WA'] * n
wal = [0] * n
ans = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if acl[p] == 'WA':
		if s == 'WA':
			wal[p] += 1
		else:
			ans += wal[p]
			acl[p] = 'AC'
print(acl.count('AC'), ans)


(N, M) = map(int, input().split())
ansY = [0] * N
ansWA = [0] * N
for i in range(M):
	(id, ans) = input().split()
	idr = int(id) - 1
	if ans == 'AC':
		ansY[idr] = 1
	elif ans == 'WA' and ansY[idr] == 0:
		ansWA[idr] += 1
WA = sum([x * y for (x, y) in zip(ansY, ansWA)])
print(sum(ansY), WA)


(n, m) = map(int, input().split())
x = [0] * (n + 1)
t = [0] * (n + 1)
p = q = 0
for i in range(m):
	(k, l) = input().split()
	y = int(k) - 1
	if x[y] == 0:
		if l == 'WA':
			t[y] += 1
		else:
			q += t[y]
			p += 1
			x[y] = 1
print(p, q)


(N, M) = map(int, input().split())
wa = [0] * N
pen = [0] * N
ac = [0] * N
for x in range(M):
	(P, S) = input().split()
	if S == 'WA' and ac[int(P) - 1] == 0:
		wa[int(P) - 1] += 1
	elif S == 'AC' and ac[int(P) - 1] == 0:
		ac[int(P) - 1] += 1
		pen[int(P) - 1] = wa[int(P) - 1]
print(f'{sum(ac)} {sum(pen)}')


(n, m) = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]
ans = [0] * n
wa = [0] * n
ac = [0] * n
for i in range(m):
	(p, s) = (int(ps[i][0]), ps[i][1])
	if ac[p - 1] == 0:
		if s == 'WA':
			wa[p - 1] += 1
		else:
			ans[p - 1] = wa[p - 1]
			ac[p - 1] += 1
print(sum(ac), sum(ans))


(N, M) = map(int, input().split())
ac = [0] * N
wa = [0] * N
for i in range(M):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC':
		ac[p] = 1
	elif ac[p] == 0:
		wa[p] += 1
print(sum(ac), sum([[0, wa[x]][ac[x]] for x in range(N)]), sep=' ')


(N, M) = map(int, input().split())
ac = 0
wa = 0
ref = [0] * N
for i in range(M):
	(p, s) = map(str, input().split())
	p = int(p) - 1
	if ref[p] != -1:
		if s == 'WA':
			ref[p] += 1
		else:
			wa += ref[p]
			ac += 1
			ref[p] = -1
print(ac, wa)


(N, M) = map(int, input().split())
ac = (N + 1) * [0]
wa = (N + 1) * [0]
pt = 0
for i in range(M):
	(p, s) = input().split()
	p = int(p)
	if ac[p] == 0 and s == 'AC':
		ac[p] = 1
		pt += wa[p]
	wa[p] += 1
print(sum(ac), pt)


(N, M) = map(int, input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
	(p, s) = map(str, input().split())
	p = int(p)
	lis[p - 1].append(s)
for j in range(N):
	if lis[j].count('AC') > 0:
		a += 1
		w += lis[j].index('AC')
print(a, w)


import numpy as np
(n, m) = map(int, input().split())
ac = [0] * (n + 1)
wa = [0] * (n + 1)
for _ in range(m):
	(p, s) = map(str, input().split())
	if s == 'AC' and ac[int(p)] == 0:
		ac[int(p)] = 1
	if s == 'WA' and ac[int(p)] == 0:
		wa[int(p)] += 1
print(sum(ac), sum(np.array(ac) * np.array(wa)))


(n, m) = map(int, input().split())
a = [input().split() for i in range(m)]
wa = [0] * n
ac = [0] * n
for i in range(m):
	if a[i][1] == 'AC':
		ac[int(a[i][0]) - 1] = 1
	elif ac[int(a[i][0]) - 1] == 0:
		wa[int(a[i][0]) - 1] += 1
(cnt1, cnt2) = (0, 0)
for i in range(n):
	if ac[i] == 1:
		cnt1 += ac[i]
		cnt2 += wa[i]
print(cnt1, cnt2)


(n, m) = map(int, input().split())
(d, c, wa) = ([0] * n, 0, 0)
for _ in range(m):
	(p, a) = input().split()
	p = int(p) - 1
	if d[p] != -1:
		if 'W' in a:
			d[p] += 1
		else:
			wa += d[p]
			d[p] = -1
			c += 1
print(c, wa)


(N, M) = map(int, input().split())
penalty = [0] * N
result = ['WA'] * N
for i in range(M):
	(P, S) = input().split()
	if S == 'AC':
		result[int(P) - 1] = 'AC'
	elif S == 'WA' and result[int(P) - 1] == 'WA':
		penalty[int(P) - 1] += 1
	else:
		continue
for j in range(N):
	if result[j] == 'WA':
		penalty[j] = 0
print(result.count('AC'), sum(penalty))


(n, m) = map(int, input().split())
judge = [0] * n
cor = 0
pen = 0
inf = 10 ** 6
for i in range(m):
	(a, s) = input().split()
	a = int(a)
	if s == 'WA':
		judge[a - 1] += 1
	elif judge[a - 1] > -1:
		cor += 1
		pen += judge[a - 1]
		judge[a - 1] = -inf
print(cor, pen)


(N, M) = map(int, input().split())
AC = [0] * (N + 1)
WA = [0] * (N + 1)
cnt_AC = 0
cnt_WA = 0
for _ in range(M):
	(i, s) = input().split()
	i = int(i)
	if AC[i] == 0:
		if s == 'WA':
			WA[i] += 1
		if s == 'AC':
			AC[i] = 1
			cnt_WA += WA[i]
cnt_AC = sum(AC)
print(cnt_AC, cnt_WA)


(N, M) = map(int, input().split())
AC = ['false'] * N
WA = [0] * N
wa = 0
ac = 0
for i in range(M):
	(p, s) = input().split()
	p = int(p)
	if s == 'AC':
		if AC[p - 1] == 'false':
			AC[p - 1] = 'True'
			ac += 1
			wa += WA[p - 1]
	else:
		WA[p - 1] += 1
print(ac, wa)


(n, m) = map(int, input().split())
judge = ['WA'] * n
count = [0] * n
ac = 0
pena = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC' and judge[p] == 'WA':
		judge[p] = 'AC'
		ac += 1
		pena += count[p]
	elif s == 'WA':
		count[p] += 1
print(ac, pena)


(n, m) = map(int, input().split())
p_s = [list(map(str, input().split())) for _ in range(m)]
ac = [False] * n
wa = [0] * n
for (p, s) in p_s:
	if ac[int(p) - 1] is False:
		if s == 'AC':
			ac[int(p) - 1] = True
		else:
			wa[int(p) - 1] += 1
print(sum([1 for i in ac if i == True]), sum([i for (i, j) in zip(wa, ac) if j == True]))


(n, m) = map(int, input().split())
ac = [0] * n
wa = [0] * n
ans = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC' and ac[p] == 0:
		ac[p] = 1
		ans += wa[p]
	wa[p] += 1
print(sum(ac), ans)


(N, M) = map(int, input().split())
penas = [0] * N
(acs, pena) = (set(), 0)
for _ in range(M):
	(p, stat) = input().split()
	p = int(p) - 1
	if stat == 'AC' and p not in acs:
		acs.add(p)
		pena += penas[p]
	else:
		penas[p] += 1
print(len(acs), pena)


(N, M) = map(int, input().split())
l = [0 for _ in range(N)]
AC = 0
WA = 0
for _ in range(M):
	(p, S) = input().split()
	p = int(p) - 1
	if l[p] != None and S == 'WA':
		l[p] += 1
	if l[p] != None and S == 'AC':
		AC += 1
		WA += l[p]
		l[p] = None
print(AC, WA)


d = dict()
wa = ac = 0
(N, M) = map(int, input().split())
for i in range(M):
	(a, b) = input().split()
	if a not in d:
		d[a] = 0
	if d[a] >= 0 and b == 'AC':
		ac += 1
		wa += d[a]
		d[a] = -1
	elif d[a] >= 0:
		d[a] += 1
print(ac, wa)


(n, m) = map(int, input().split())
x = [True] * n
cnt = [0] * n
y = 0
z = 0
for i in range(m):
	(p, s) = input().split()
	if s == 'AC':
		x[int(p) - 1] = False
	elif x[int(p) - 1]:
		cnt[int(p) - 1] += 1
for i in range(n):
	if x[i] == False:
		z += cnt[i]
		y += 1
print(y, z)


(N, M) = map(int, input().split())
ans = [0] * N
pen = [0] * N
AC = [0] * N
for i in range(M):
	(p, s) = input().split()
	p = int(p)
	if s == 'WA':
		pen[p - 1] += 1
	else:
		if AC[p - 1] == 0:
			ans[p - 1] += pen[p - 1]
		AC[p - 1] = 1
print(AC.count(1), sum(ans))


(n, m) = map(int, input().split(' '))
ac = 0
wa = 0
en_li = [[] for i in range(n)]
print
for i in range(m):
	(a, b) = input().split(' ')
	en_li[int(a) - 1].append(b)
ac = 0
wa = 0
for i in en_li:
	if 'AC' in i:
		wa += i.index('AC')
		ac += 1
print(ac, wa)


(N, M) = map(int, input().split())
(s, p) = ([False] * N, [0] * N)
for i in range(M):
	tmp = input().split()
	(pi, Si) = (int(tmp[0]) - 1, tmp[1])
	s[pi] |= Si == 'AC'
	p[pi] += 1 if not s[pi] else 0
print(sum(s), sum([pi for (si, pi) in zip(s, p) if si]))


(n, m) = map(int, input().split())
ac = [0] * n
wa = [0] * n
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if not ac[p]:
		if s == 'AC':
			ac[p] = 1
		else:
			wa[p] += 1
was = 0
for i in range(n):
	if ac[i]:
		was += wa[i]
print(sum(ac), was)


from collections import defaultdict
(N, M) = map(int, input().split())
wa = defaultdict(int)
ac = {}
for i in range(M):
	(p, S) = input().split()
	if S == 'AC':
		ac[p] = True
	elif p not in ac:
		wa[p] += 1
print(len(ac), sum([wa[x] for x in ac.keys()]))


(n, m) = map(int, input().split())
acwa = [[] for _ in range(n)]
for i in range(m):
	(pp, ss) = input().split()
	acwa[int(pp) - 1].append(ss)
n_ac = 0
n_wa = 0
for i in range(n):
	if 'AC' in acwa[i]:
		n_ac += 1
		n_wa += acwa[i].index('AC')
print(n_ac, n_wa)


d = [0] * 10 ** 5
a = set()
w = 0
for t in open(0):
	(p, s) = t.split()
	p = int(p)
	if 'AC' == s and p not in a:
		w += d[p]
		a.add(p)
	if 'WA' == s:
		d[p] += 1
print(len(a), w)


(n, m) = map(int, input().split())
ac_cnt = set()
wa_cnt = 0
penalty = [0] * n
for i in range(m):
	(p, s) = input().split()
	num = int(p) - 1
	if num not in ac_cnt:
		if s == 'AC':
			ac_cnt.add(num)
			wa_cnt += penalty[num]
		else:
			penalty[num] += 1
print(len(set(ac_cnt)), wa_cnt)


(n, m) = map(int, input().split())
ac_cnt = 0
wa_cnt = 0
d = {}
for _ in range(m):
	(p, s) = input().split()
	if p not in d:
		d[p] = [s]
	else:
		d[p].append(s)
for i in d:
	if 'AC' in d[i]:
		ac_cnt += 1
		wa_cnt += d[i].index('AC')
print(ac_cnt, wa_cnt)


(n, m) = map(int, input().split())
p = []
s = []
for i in range(m):
	(p_i, s_i) = input().split()
	p.append(int(p_i))
	s.append(s_i)
correct = [0] * n
penalty = [0] * n
for i in range(m):
	no = p[i]
	if correct[no - 1] == 1:
		continue
	elif s[i] == 'WA':
		penalty[no - 1] += 1
	elif s[i] == 'AC':
		correct[no - 1] = 1
pen = 0
for i in range(n):
	if correct[i] == 1:
		pen += penalty[i]
print(sum(correct), pen)


(N, M) = map(int, input().split())
A = [0] * (N + 1)
ac = 0
pe = 0
for i in range(M):
	(p, S) = input().split()
	if A[int(p)] == -1:
		continue
	if S == 'AC':
		ac += 1
		pe += A[int(p)]
		A[int(p)] = -1
	else:
		A[int(p)] += 1
print(ac, pe)


(N, M) = map(int, input().split())
AC_list = [0] * N
WA_list = [0] * N
for i in range(M):
	(p, j) = input().split()
	p = int(p)
	if j == 'AC':
		AC_list[p - 1] += 1
	elif AC_list[p - 1] == 0:
		WA_list[p - 1] += 1
AC = 0
WA = 0
for i in range(N):
	if AC_list[i] >= 1:
		AC += 1
		WA += WA_list[i]
print(AC, WA)


(N, M) = [int(n) for n in input().split()]
submit = []
AC = [0] * N
WA = [0] * N
for i in range(M):
	(p, s) = [n for n in input().split()]
	p = int(p)
	if AC[p - 1] == 1:
		continue
	if s == 'AC':
		AC[p - 1] = 1
	elif s == 'WA':
		WA[p - 1] += 1
pen = [x * y for (x, y) in zip(AC, WA)]
print(sum(AC), sum(pen))


(N, M) = map(int, input().split())
AC = [0] * N
WA = [0] * N
for _ in range(M):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC':
		AC[p] = 1
	elif AC[p] < 1:
		WA[p] += 1
WA = [w if AC[p] else 0 for (p, w) in enumerate(WA)]
print(sum(AC), sum(WA))


(N, M) = map(int, input().split())
ACList = [0] * (N + 1)
ansAC = 0
ansP = 0
for i in range(M):
	(p, S) = map(str, input().split())
	p = int(p)
	if S == 'AC' and ACList[p] != -1:
		ansAC += 1
		ansP += ACList[p]
		ACList[p] = -1
	elif S == 'WA' and ACList[p] != -1:
		ACList[p] += 1
	else:
		continue
print(ansAC, ansP)


(n, m) = map(int, input().split())
ans = 0
l = [0] * n
d = {}
for i in range(m):
	(p, s) = input().split()
	q = int(p) - 1
	if q in d:
		continue
	if s == 'AC':
		ans += l[q]
		d[q] = s
	else:
		l[q] += 1
print(len(d), ans)


def resolve():
	(n, m) = map(int, input().split())
	ac_list = [0] * n
	wa_count = [0] * n
	ac = 0
	wa = 0
	for _ in range(m):
		(p, s) = input().split()
		if s == 'WA' and ac_list[int(p) - 1] == 0:
			wa_count[int(p) - 1] += 1
		elif s == 'AC' and ac_list[int(p) - 1] == 0:
			ac += 1
			ac_list[int(p) - 1] = 1
	for (i, j) in zip(wa_count, ac_list):
		if j:
			wa += i
	print(f'{ac} {wa}')
resolve()


(n, m) = map(int, input().split())
res = [0 for i in range(n)]
P = [0 for i in range(n)]
ans = 0
p = 0
for i in range(m):
	(pi, si) = input().split()
	pi = int(pi) - 1
	if res[pi]:
		continue
	if si == 'AC':
		res[pi] = 1
		ans += 1
		p += P[pi]
	else:
		P[pi] += 1
print(ans, p)


(w, *d) = [0] * 10 ** 6
a = {0}
for t in open(0):
	(p, s) = t.split()
	p = int(p)
	if 'AC' == s * (not p in a):
		w += d[p]
		a |= {p}
	d[p] += s > 'V'
print(len(a) - 1, w)


(n, m) = map(int, input().split())
qaw = [[0, 0] for i in range(n)]
x = 0
y = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p) - 1
	if s == 'AC':
		qaw[p][0] = 1
	elif qaw[p][0] == 0:
		qaw[p][1] += 1
for q in qaw:
	if q[0] == 1:
		x += 1
		y += q[1]
print(x, y)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(sa, lw) = (set(), [0] * n)
for _ in range(m):
	(p, s) = input().split()
	if p in sa:
		continue
	if s == 'AC':
		sa.add(p)
	else:
		lw[int(p) - 1] += 1
print(len(sa), sum((lw[int(p) - 1] for p in sa)))


(N, M) = map(int, input().split())
a = [False] * N
w = [0] * N
for i in range(M):
	(p, S) = input().split()
	if S == 'AC':
		a[int(p) - 1] = True
	elif not a[int(p) - 1]:
		w[int(p) - 1] += 1
print(a.count(True), sum([w[i] if a[i] else 0 for i in range(N)]))


(N, M) = map(int, input().split())
p = [0] * M
S = ['a'] * M
x = [0] * N
y = [0] * N
for i in range(M):
	(p[i], S[i]) = input().split()
	k = int(p[i]) - 1
	if x[k] == 0:
		if S[i] == 'WA':
			y[k] += 1
		else:
			x[k] = 1
z = sum(x)
w = 0
for i in range(N):
	if x[i] == 1:
		w += y[i]
print(z, w)


(n, m) = map(int, input().split())
r = [False] * n
w = [0] * n
ok = 0
ng = 0
for i in range(m):
	(p, s) = input().split()
	p = int(p)
	p -= 1
	if s == 'AC':
		if r[p] == False:
			ok += 1
			ng += w[p]
			r[p] = True
	else:
		w[p] += 1
print(ok, ng)


(N, M) = map(int, input().split())
(AC, WA, C) = (0, 0, [0] * N)
for _ in range(M):
	(p, S) = input().split()
	p = int(p) - 1
	if C[p] >= 0:
		if S == 'AC':
			(AC, WA, C[p]) = (AC + 1, WA + C[p], -1)
		else:
			C[p] += 1
print(AC, WA)


(n, m) = map(int, input().split())
q = [0 for i in range(n)]
a = [False for i in range(n)]
ans1 = 0
ans2 = 0
for i in range(m):
	(p, S) = input().split()
	p = int(p) - 1
	if S == 'AC':
		a[p] = True
	elif a[p] == False:
		q[p] += 1
for i in range(n):
	if a[i] == True:
		ans1 += 1
		ans2 += q[i]
print(ans1, ans2)