Problem:
 Score : 300 points    Problem Statement 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 WA s 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 1 2 5
1 WA
1 AC
2 WA
2 AC
2 WA      Sample Output 1 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.       Sample Input 2 100000 3
7777 AC
7777 AC
7777 AC      Sample Output 2 1 0  Note that it is pointless to get an AC more than once on the same problem.       Sample Input 3 6 0      Sample Output 3 0 0

Solution (Python):
n, m = [int(el) for el in input().split(' ')]
df = []
for i in range(m):
	df.append(input().split(' '))

record = []
for i in range(n):
	record.append([0,0])

for i in range(m):
	x = df[i][1]
	q = int(df[i][0])
	if record[q-1][0] == 1:
		pass
	else:
		if x == "AC":
			record[q-1][0] = 1
		else:
			record[q-1][1] += 1

ans = 0
for i in range(n):
	ans += record[i][0]


pen = 0
for i in range(n):
	if record[i][0] > 0:
		pen += record[i][1]

print(ans, pen)

Solution (Python):
n,m=map(int,input().split())
A={}
for i in range(m):
    num,result=input().split()
    if num not in A:
        A[num]=[result]
    else:
        A[num] +=[result]

ans,cnt=0,0
for v,m in A.items():
    if "AC" not in m:continue
    for i in m:
        if i=="AC":
            ans +=1
            break
        if i=="WA":
            cnt +=1

print(ans,cnt)

Solution (Python):
n,m = map(int, input().split())

check = {}
error = {}

ans_ac = 0
ans_wa = 0

for i in range(m):
    p,s = map(str, input().split())
    p = int(p)
    if p in check:
        pass
    else:
        if s == "WA":
            if p in error:
                error[p] += 1
            else:
                error[p] = 1
        else:
            if p in check:
                check[p] += 1
            else:
                check[p] = 1
            if p in error:
                ans_wa += error[p]
            ans_ac += 1
print(str(ans_ac) + " " + str(ans_wa) )

Solution (Python):
def solve():
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    
    cleared = dict(zip(range(N), [False] * N))
    penalty = dict(zip(range(N), [0] * N))
    
    for i in range(M):
        p, S = f_i.readline().split()
        p = int(p) - 1
        if S == 'AC':
            cleared[p] = True
        elif not cleared[p]:
            penalty[p] += 1
    
    clear_count = list(cleared.values()).count(True)
    
    penalty_count = 0
    for k, v in penalty.items():
        if cleared[k]:
            penalty_count += v
    
    print(clear_count, penalty_count)

solve()

Solution (Python):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
pS = [input().split()[:2] for _ in range(m)]

AC = [0]*n
WA = [0]*n

for p, S in pS:
    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 WA[i] > 0 and AC[i] == 0:
        WA[i] = 0
print(sum(AC), sum(WA))

Solution (Python):
nm = input().split(' ');
n = int(nm[0]);
m = int(nm[1]);
flag = [0]*(n+1);
count_wa = [0]*(n+1);

for i in range(m) :
	ps = input().rstrip('\n');
	ps = ps.split(' ');
	p = int(ps[0]);
	s = ps[1];
	if flag[p] == 0 and s == 'AC' :
		flag[p] = 1;
	elif flag[p] == 0 and s == 'WA' :
		count_wa[p] += 1;

for i in range(n+1) :
	if flag[i] == 0 :
		count_wa[i] = 0;

print(sum(flag),sum(count_wa));

Solution (Python):

n, m = list(map(int,input().split()))
a = [0]*(n+1)
w = [0]*(n+1)
wrong = 0
for _ in range(m):
    p, s = list(map(str,input().split()))
    p = int(p)
    if s == "WA":
        w[p] +=1
    if s == "AC":
        if a[p] == 0:
            a[p] = 1
            wrong += w[p]
print(sum(a),wrong)

Solution (Python):
n, m = map(int, input().split())
p = [0 for _ in range(m)]
s = ["" for _ in range(m)]
for i in range(m):
    pi, si = input().split()
    p[i] = int(pi)
    s[i] = si
ac = set()
acc = set()
wa = 0
for i in range(m):
    if s[i] == "AC" and p[i] not in ac:
        acc.add(p[i])
for i in range(m):
    if s[i] == "AC" and p[i] not in ac:
        ac.add(p[i])
    elif s[i] == "WA" and p[i] not in ac and p[i] in acc:
        wa += 1

print(len(ac), wa)

Solution (Python):
N, M = list(map(int, input().split()))
WA, AC = "WA", "AC"

ac = [0] * (N+1)
wa = [0] * (N+1)

for i in range(1, M+1):
  p, S = input().split()
  p = int(p)
  if S == WA and ac[p] == 0:
    wa[p] += 1
  elif S == AC and ac[p] == 0:
    ac[p] = 1

wa = [v*ac[i] for i,v in enumerate(wa)]
    
print(sum(ac), sum(wa))

Solution (Python):
def c_welcome_to_atcoder():
    N, M = [int(i) for i in input().split()]
    Results = []
    for _ in range(M):
        p, s = input().split()
        Results.append((int(p), s))

    count_wa = [0] * (N + 1)
    is_already_ac = [False] * (N + 1)

    for p, s in Results:
        if is_already_ac[p]:
            continue

        if s == 'AC':
            is_already_ac[p] = True
        elif s == 'WA':
            count_wa[p] += 1

    ans_ac = 0
    ans_wa = 0
    for ac, wa in zip(is_already_ac, count_wa):
        if ac:
            ans_ac += 1
            ans_wa += wa
    return '{} {}'.format(ans_ac, ans_wa)

print(c_welcome_to_atcoder())

Solution (Python):

N, M = map(int, input().split())
lst = [list(input().split()) for i in range(M)]
ans = [[0,0] for i in range(N)]
for i in lst:
  if (i[1] == 'WA'):
    if (ans[int(i[0])-1][1] != 1):
      ans[int(i[0])-1][0] += 1
  else:
    if (ans[int(i[0])-1][1] == 0):
      ans[int(i[0])-1][1] += 1
ac = 0
wa = 0
for i in ans:
  if (i[1] == 1):
    ac += 1
    wa += i[0]
print(ac, wa)

Solution (Python):
import math
import fractions

n, m = map(int, input().split())
ac_list = [0 for _ in range(n)]
wa_list = [0 for _ in range(n)]
wa_cnt = 0
cnt = 1
while cnt <= m:
    p, s = input().split()
    p = int(p)
    if s == "AC":
        ac_list[p - 1] = 1
    else:
        if ac_list[p - 1] == 0:
            wa_list[p - 1] += 1
    cnt += 1
for i in range(n):
    if wa_list[i] >= 1 and ac_list[i] == 1:
        wa_cnt += wa_list[i]
print(sum(ac_list), wa_cnt)

Solution (Python):
n,m=map(int,input().split())
p=[0]*m
s=['0']*m
wa = [0]*n
ac = [0]*n
for i in range(m):
    p[i],s[i]=input().split()
    p[i]=int(p[i])
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(n):
    if ac[i]==0:
        wa[i]=0
ans=[sum(ac),sum(wa)]
for i in range(len(ans)):
    print(ans[i], end=' ')

Solution (Python):
n, m = map(int,input().split())

corrects = [0] * n
wrongs = [0] * n

for i in range(m):
  p, cw = input().split()
  num = int(p) - 1
  if cw == "AC" and corrects[num] == 0:
    corrects[num] += 1
  if cw == "WA" and corrects[num] == 0:
    wrongs[num] += 1

print(sum(corrects))

wrong_ans = 0
for i in range(n):
  if corrects[i] == 1:
    wrong_ans += wrongs[i]
    
print(wrong_ans)

Solution (Python):
n,m = map(int,input().split())
p = [list(map(str,input().split())) for i in range(m)]
answa = [0] * (n+1)
ans = [False] * (n+1)


for i in range(m):
    
    
    
    
    if p[i][1] == "WA" and ans[int(p[i][0])] == False:
        answa[int(p[i][0])] += 1
    elif p[i][1] == "AC":
        ans[int(p[i][0])] = True

tmp = 0

for i in range(1,n+1):
    if ans[i]:
        tmp += answa[i]

print(sum(ans),tmp)

Solution (Python):
N,M=map(int, input().split())
results = [[0,0] for i in range(N)]
wa=0
ac=0
for i in range(M):
    P,S=map(str, input().split())
    P = int(P) - 1
    if S == 'AC':
        if results[P][0] == 0:
            wa += results[P][1]
            results[P][1] = 0
            ac += 1
            results[P][0] += 1
    else:
        results[P][1] += 1

print("{0} {1}".format(ac,wa))

Solution (Python):
n,m=map(int,input().split())

dict = {}
for i in range(m):
    p,s=input().split()
    dict.setdefault(p,[]).append(s)

ac_count=0
wa_count=0
for p,s in dict.items():
    is_ac=False
    wa_tmp_count=0
    for ans in s:
        if ans=='AC':
            ac_count+=1
            is_ac=True
        else:
            wa_tmp_count+=1
        if is_ac:
            wa_count+=wa_tmp_count
            break
print(ac_count, wa_count)

Solution (Python):
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]

ac = [0] * n
wa = [0] * n

for p, s in ps:
    p = int(p) - 1
    if ac[p] == 0:
        if s == "AC":
            ac[p] = 1
        else:
            wa[p] += 1

wa = [ac[i] * wa[i] for i in range(n)]
print(sum(ac),sum(wa))

Solution (Python):
n,m=map(int, input().split())

ok=0
ac = [0]*n
penalty = [0]*n

for i in range(m):
    p,s = input().split()
    p=int(p)
    if s=="WA":
        if ac[p-1]==0:
            penalty[p-1]+=1
    elif s=="AC":
        if ac[p-1]==0:
            ok+=1
            ac[p-1]=1
ans=0
for i in range(n):
    if ac[i]==1:
        ans+=penalty[i]
print(ok,ans)

Solution (Python):
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)

Solution (Python):
n, m = map(int, input().split())
a = [0] * n
ans_1 = 0
ans_2 = 0
for i in range(m):
    p, s = map(str, input().split())
    if a[int(p) - 1] >= 0:
        if s == "WA":
            a[int(p) - 1] += 1
            ans_2 += 1
        else:
            a[int(p) - 1] = -1
            ans_1 += 1
for i in range(n):
    if a[i] > 0:
        ans_2 -= a[i]
print(ans_1, ans_2)

Solution (Python):
N, M = map(int, input().split())

cnt = [[0, 0] for _ in range(N)]

res = [0, 0]
for i in range(M):
    p, s = input().split()
    p = int(p) - 1

    if cnt[p][0] > 0:
        continue

    if s == "AC":
        cnt[p][0] += 1
        res[0] += 1
        res[1] += cnt[p][1]
    elif s == "WA":
        cnt[p][1] += 1

print(res[0], res[1])

Solution (Python):
N, M = map(int,input().split())
ps = dict()
for m in range(M):
    a = input().split()
    if a[0] not in ps:
        ps[a[0]] = []
    ps[a[0]].append(a[1])
ans = [0, 0]
for x in ps:
    if "AC" in ps[x]:
        for y in ps[x]:
            if y == "WA":
                ans[1] += 1
            else:
                ans[0] += 1
                break
print(ans[0],ans[1])

Solution (Python):
n, m = map(int, input().split())
was = [0 for _ in range(n)]
counting = [-1 for _ in range(n)] 
for _ in range(m):
  result = input().split()
  p = int(result[0])
  s = result[1]
  if s == "WA" and counting[p-1] <= 0:
    was[p-1] += 1
  elif s == "AC" and counting[p-1] <= 0:
    counting[p-1] = 1

ac_count = 0
wa_count = 0
for i in range(n):
  if counting[i] == 1:
    ac_count += 1
    wa_count += was[i]

ret = str(ac_count) + " " + str(wa_count)
print(ret)

Solution (Python):
N, M = map(int, input().split())
pS = [list(input().split()) for _ in range(M)]

memo = [[0] * 2 for _ in range(N)]
memo_WA = [0] * N

answer_AC = 0
answer_WA = 0

for i in range(M):
    if memo[int(pS[i][0]) - 1][0] == 1:
        continue
    elif pS[i][1] == "AC":
        answer_AC += 1
        memo[int(pS[i][0]) - 1][0] = 1
    else:
        memo_WA[int(pS[i][0]) - 1] += 1

for i in range(N):
    if memo[i][0] == 1:
        answer_WA += memo_WA[i]

print(answer_AC)
print(answer_WA)

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

Solution (Python):
n,m = map(int,input().split())
result = ["mada"]*n
wac = [0]*n
AC = 0
WA = 0
p = []
s = []
for i in range(m):
    pi,si = map(str,input().split())
    p.append(int(pi))
    s.append(si)

for i in range(m):
    pp = p[i]
    ss = s[i]
    if ss == "WA":
        if result[pp-1] == "mada":
            wac[pp-1] += 1
        elif result[pp-1] == "AC":
            continue
    elif ss == "AC":
        if result[pp-1] == "mada":
            result[pp-1] = "AC"
        elif result[pp-1] == "AC":
            continue

for i in range(n):
    if result[i] == "AC":
        AC += 1
        WA += wac[i]

print(AC,WA)

Solution (Python):
N , M = map(int,input().split())
lst = []
AC_list = [False] * N
WA_cnt_list = [0] * N
for _ in range(M):
    r , judge = input().split()
    question_num = int(r) - 1
    if AC_list[question_num]:
        continue
    elif judge == "WA":
        WA_cnt_list[question_num] += 1
    elif judge == "AC":
        AC_list[question_num] = True
wa_cnt = 0
for i in range(N):
    if AC_list[i]:
        wa_cnt += WA_cnt_list[i]
print(sum(AC_list) , wa_cnt)

Solution (Python):
N, M = map(int, input().split())
ls = tuple([] for i in range(N))
for _ in range(M):
    p, S = input().split()
    p = int(p)
    ls[p - 1].append(S)
    
cnt_crr = 0
cnt_pnt = 0

for e in ls:
    if "AC" in e:
        for _e in e:
            if _e == "AC":
                cnt_crr += 1
                break
            cnt_pnt += 1

print(cnt_crr, cnt_pnt)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    ct=[0  for i in range(100001)]
    li=[]
    check=[0  for i in range(100001)]
    for i in range(m):
        p,s=STRM()
        p=int(p)
        li.append([p,s])
    for i in range(len(li)):
        if check[li[i][0]]==0:
            if li[i][1]=='WA':
                ct[li[i][0]]+=1
            else:
                check[li[i][0]]=1
        else:
            pass
    for i in range(100001):
        if check[i]==0:
            ct[i]=0
        else:
            pass
    
    ct_s=sum(ct)
    ck_s=sum(check)
    print(ck_s,ct_s)
if __name__ == '__main__':
    do()

Solution (Python):
n,m = map(int,input().split())
ans = [0]*2
tmp = [0]*n
false = [0]*n
for _ in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if tmp[p-1] == 0:
        if s == 'AC':
            ans[0] += 1
            tmp[p-1] += 1
            ans[1] += false[p-1]
        elif s == 'WA':
            false[p-1] += 1
print(*ans)

Solution (Python):
n, m = map(int,input().split())
result = []
for _ in range(m):
    a, b = input().split()
    a = int(a)
    result.append([a, b])
problems = [0] * (n+1)
ac = 0
wa = 0
for i in range(m):
    if problems[result[i][0]-1] != -1:
        if result[i][1] == "AC":
            ac += 1
            wa += problems[result[i][0]-1]
            problems[result[i][0]-1] = -1
        else:
            problems[result[i][0]-1] += 1

print(ac, wa)

Solution (Python):
N, M = map(int, input().split())
data = [input().split() for _ in range(M)]

anslist = [0]*(N+1)
wanslist = [0]*(N+1)
AC = 0
WA = 0
for i in range(M):
    if anslist[int(data[i][0])] == 1:
        continue
    else:
        if data[i][1] == "AC":
            anslist[int(data[i][0])] = 1
            AC += 1
        else:
            wanslist[int(data[i][0])] += 1

for i in range(1, N+1):
    if anslist[i] == 1:
        WA += wanslist[i]

print(AC, WA)

Solution (Python):
N, M = map(int, input().split())
p = [0 for i in range(M)]
S = ["" for i in range(M)]
ACc = [False for i in range(N)]
firstans = [0 for i in range(N)]
errors = 0
answers = 0

for i in range(M):
    p[i], S[i] = input().split(" ")
    p[i] = int(p[i])

for i in range(M):
    if S[i] == "AC":
        ACc[p[i]-1] = True
        if firstans[p[i]-1] == 0:
            firstans[p[i]-1] = i


for i in range(M):
    if S[i] == "WA" and (ACc[p[i]-1]) and i <= firstans[p[i]-1]:
        errors +=1 
    

for i in range(N):
    if ACc[i]:
        answers +=1


print(answers, errors)

Solution (Python):
n, m = [int(i) for i in input().split()]

anss = [0 for i in range(n)]
all_wa = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if anss[p-1] == "AC":
        continue
    elif s == "WA":
        anss[p-1] += 1
    else:
        all_wa += anss[p-1]
        anss[p-1] = "AC"

print(anss.count("AC"), all_wa)

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

Solution (Python):
n, m = map(int, input().split())
p = [0]*m
s = [0]*m

for i in range(m):
    p[i], s[i] = input().split()
    p[i] = int(p[i])

ac_cnt = 0
wa_cnt = 0
ac_list = [0] * n
wa_list = [0] * n

for i in range(m):
    if ac_list[p[i] - 1] == 0:
        if s[i] == "WA":
            
            wa_list[p[i] - 1] += 1
        else:
            ac_list[p[i] - 1] = 1
            ac_cnt += 1
            wa_cnt += wa_list[p[i] - 1]


print(ac_cnt, wa_cnt)

Solution (Python):
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]))

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

Solution (Python):
n, m = map(int, input().split())
arr = [input().split() for _ in range(m)]

dic = {x: [] for x in range(1, n+1)}
for p, s in arr:
    dic[int(p)].append(s)

ac = 0
wa = 0
for k, v in dic.items():
    tmp = 0
    for x in v:
        if x == 'AC':
            ac += 1
            wa += tmp
            break
        else:
            tmp += 1

print(ac, wa)

Solution (Python):

n,m = map(int,input().split())
nlis = [0] * n
ac = 0
wa = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) -1
    if nlis[p] == -1:
        continue
    if s == "WA":
        nlis[p] += 1
    else:
        ac += 1
        wa += nlis[p]
        nlis[p] = -1
print(ac,wa)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    ac = set()
    wa = [0] * (n+1)

    for _ in range(m):
        p, s = input().split()
        p = int(p)
        if p in ac:
            continue
        if s == 'AC':
            ac.add(p)
        elif s == 'WA':
            wa[p] += 1
    wa = [j for i, j in enumerate(wa) if i in ac]
    print(len(ac), sum(wa))

if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
plist = [0 for _ in range(n)]
acornot = [0]*n
ans = 0
for i in range(m):
    p,s = input().split()
    p = int(p)
    p -= 1
    if s == "AC" and acornot[p] != 1:
        
        ans += 1
        acornot[p] = 1
    elif s == "AC" and acornot[p] ==1:
        continue
    elif s == "WA" and acornot[p] == 1:
        continue
    else:
        plist[p]+=1
print(ans)
ansp = 0
for i in range(n):
    if acornot[i] == 0:
        continue
    else:
        ansp+=plist[i]
print(ansp)

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

for j in range(N+1):
    WA[j] = WA[j]*AC[j]
    
print(sum(AC),sum(WA))

Solution (Python):
n, m = map(int, input().split(' '))

pena = [0 for i in range(n)]
acc = [0 for i in range(n)]

for i in range(m):
    pp, ss = input().split(' ')
    p = int(pp) - 1

    if acc[p] == 0:
        if ss == 'WA':
            pena[p] += 1
        else:
            acc[p] = 1

for i in range(n):
    pena[i] = pena[i] * acc[i]

print(sum(acc), sum(pena))

Solution (Python):
import numpy as np
n,m = map(int, input().split())
a = [False]*n
b = [0]*n
for i in range(m):
  p,s = map(str,input().split())
  p = int(p)-1
  if s == "AC":
    a[p] = True
  else:
    if a[p] == False:
      b[p]=b[p]+1
print(np.array(a).sum(),np.array(b)[np.array(a)].sum())

Solution (Python):


N, M = list(map(int, input().split()))
ps_list = [[] for _ in range(N)]

for _ in range(M):
    p, s = list(input().split())
    p = int(p) - 1
    ps_list[p].append(s)

wa_c = 0
ac_c = 0
total_wa_c = 0

for i, ss in enumerate(ps_list):
    wa_c = 0
    for s in ss:
        if s == "WA":
            wa_c += 1
        else:
            ac_c += 1
            total_wa_c += wa_c
            break

ans = "{} {}".format(ac_c, total_wa_c)
print(ans)

Solution (Python):
N, M = map(int, input().split())
flags = [False for _ in range(N)]
WAs = [0 for _ in range(N)]
pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'AC' and not flags[p]:
        flags[p]=True
        pen += WAs[p]
    if not flags[p]:
        WAs[p] += 1
acc = flags.count(True)
print(acc, pen)

Solution (Python):
N, M = map(int, input().split())
acs = [0] * N
was = [0] * N
for m in range(M):
    p, S = input().split()
    
    if S == 'AC':
        acs[int(p) - 1] = 1
    else:
        if acs[int(p) - 1] == 0:
            was[int(p) - 1] += 1

ac_count = sum(acs)

for n in range(N):
    if acs[n] == 0:
        was[n] = 0
wa_count = sum(was)
print(ac_count, wa_count)

Solution (Python):

N, M = map(int, input().split())

p_list = []
S_list = []
ac_set = set([])
wa_list = [0 for i in range(N)]
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if p not in ac_set:
        if S == "AC":
            ac_set.add(p)
        else:
            wa_list[p - 1] += 1

wa_num = 0
for i in ac_set:
    wa_num += wa_list[i - 1]
print("{} {}".format(len(ac_set), wa_num))

Solution (Python):
n,m=map(int,input().split())
sub=[ input().split() for i in range(m)]
sub=[[int(i[0]),i[1]] for i in sub]

mis=[[0,0] for i in range(n)]

for i in range(m):
  if sub[i][1]=='AC':
    mis[sub[i][0]-1][0]=1
  elif sub[i][1]=='WA' and mis[sub[i][0]-1][0]!=1:
    mis[sub[i][0]-1][1]+=1
    
ans=[0,0]
for i in range(n):
  if mis[i][0]==1:
    ans[0]+=1
    ans[1]+=mis[i][1]
print(ans[0],ans[1])

Solution (Python):
N, M = map(int, input().split())
flags = [0 for _ in range(N)]

ans = 0
pena = 0
for p, s in [input().split() for _ in range(M)]:
    p = int(p)
    if flags[p-1] is not False:
        if s == "WA":
            flags[p-1] += 1
        else:
            pena += flags[p-1]
            flags[p-1] = False
            ans += 1

print(ans, pena)

Solution (Python):
N, M = list(map(int, input().split()))

WAs = [0] * (N + 1)
ACs = [0] * (N + 1)
for m in range(M):
  key, value = input().split()
  key = int(key)
  if value == 'WA' and ACs[key] == 0:
    WAs[key] += 1
  if value == 'AC':
    ACs[key] = 1

countWAs, countACs = 0, 0
for n in range(N + 1):
  if ACs[n] >= 1:
    countACs += ACs[n]
    countWAs += WAs[n]



print(str(countACs) + ' ' + str(countWAs))

Solution (Python):
N, M = map(int, input().split())

ac_counts = [0 for i in range(N + 1)]
wa_counts = [0 for i in range(N + 1)]
is_AC = [False for i in range(N + 1)]

for i in range(M):
  p, S = input().split()
  p = int(p)
  if not is_AC[p]:
    if S == "AC":
      ac_counts[p] += 1
      is_AC[p] = True
    else:
      wa_counts[p] += 1

ac_cnt, wa_cnt = 0, 0
for flag, _ac_cnt, _wa_cnt in zip(is_AC, ac_counts, wa_counts):
  if flag:
    ac_cnt += _ac_cnt
    wa_cnt += _wa_cnt

print(ac_cnt, wa_cnt)

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    a = [[] for _ in range(N)]
    for _ in range(M):
        p, s = input().split()
        a[int(p)-1].append(s)
    correct = 0
    pena = 0
    for q in a:
        if 'AC' in q:
            correct += 1
            for qq in q:
                if qq == 'WA':
                    pena += 1
                else:
                    break
    print(correct, pena)

resolve()

Solution (Python):
n, m = map(int, input().split())
L = []
for i in range(m):
  L.append([i for i in input().split()])
Lcorr = [0 for i in range(n)]
Lflag = [0 for i in range(n)]
Lpena = [0 for i in range(n)]

for i in range(m):
  if Lflag[int(L[i][0])-1] == 0 and L[i][1] == "AC":
    Lcorr[int(L[i][0])-1] += 1
    Lflag[int(L[i][0])-1] = 1
  if int(Lflag[int(L[i][0])-1]) == 0 and L[i][1] == "WA":
    Lpena[int(L[i][0])-1] += 1
    
for j in range(n):
  if Lflag[j] == 0:
    Lpena[j] = 0

corr = sum(Lcorr)
pena = sum(Lpena)
print("{0} {1}".format(corr, pena))

Solution (Python):
n, m = map(int,input().split())
ans = [0]*n
WA_li = [0]*n
AC = 0
WA = 0
for i in range(m):
    temp = list(map(str, input().split()))
    if ans[int(temp[0])-1] == 0:
        if temp[1] == "AC":
            ans[int(temp[0])-1] = 1
            AC += 1 
        else:
            WA_li[int(temp[0])-1] += 1
for i in range(n):
    if ans[i] == 1:
        WA += WA_li[i]
print(AC, WA)

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
a = defaultdict(list)
b = defaultdict(int)
for i in range(M):
    li = list(input().split())
    li[0] = int(li[0])
    a[li[0]].append(li[1])
    if li[1] == 'AC':
        b[li[0]] = 1
ac = len(b)
wa = 0
for i in range(1, N+1):
    if b[i] == 1:
        for x in a[i]:
            if x == 'AC':
                break
            wa += 1
            
print(ac, wa)

Solution (Python):

import sys
from fractions import gcd
from string import ascii_uppercase as ABC

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

from itertools import permutations
N, M = inpl()
C = 0
P = 0
ac = [False]*N
pe = [0]*N

for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac[p] = True
    else:
        if ac[p] == False:
            pe[p] += 1
C = sum(ac)
P = sum([ac[i]*pe[i] for i in range(N)])
print(C, P)

Solution (Python):
N, M = map(int, input().split())
PSList = [list(input().split()) for i in range(M)]

ACWAList = []
for i in range(N):
    ACWAList.append([0, 0])

for i in range(M):
    P = int(PSList[i][0])

    if ACWAList[P-1][0] == 1:
        continue

    if PSList[i][1] == "AC":
        ACWAList[P-1][0] = 1
    else:
        ACWAList[P-1][1] += 1

ACSum = 0
WASum = 0
for i in range(N):
    if ACWAList[i][0] != 1:
        continue
    ACSum += ACWAList[i][0]
    WASum += ACWAList[i][1]

print(str(ACSum) + " " + str(WASum))

Solution (Python):
N, M = map(int, input().split())
problems = [0] * N
miss = 0
for i in range(M):
  p, S = input().split()
  p = int(p)
  if problems[p - 1] != "AC":
    if S == "WA":
      problems[p - 1] += 1
    elif S == "AC":
      miss += problems[p - 1]
      problems[p - 1] = "AC"
ans = sum([1 for i in problems if i == "AC"])
print(ans, miss)

Solution (Python):
N, M = map(int, input().split())

WA = [0] * (10 ** 5 + 1)
AC = [False] * (10 ** 5 + 1)
for i in range(M):
    _no , re = input().split()
    no = int(_no)
    if re == 'AC':
        AC[no] = True
    if not AC[no]:
        if re == 'WA':
            WA[no] += 1
pena = 0
for i in range(10 ** 5 + 1):
    if AC[i]:
        pena += WA[i]

print(AC.count(True), pena)

Solution (Python):
n,m = map(int,input().split())
hist = {}
hist_wa = {}
count_ac = count_wa = 0
for i in range(m):
  p,s = input().split()
  if p in hist:
    continue
  if s == 'AC':
    hist[p] = True
    count_ac += 1
    if p in hist_wa:
      count_wa += hist_wa[p]
  else:
    if p in hist_wa:
      hist_wa[p] += 1
    else:
      hist_wa[p] = 1
print('{} {}'.format(count_ac, count_wa))

Solution (Python):
n, m = map(int, input().split())
ps = []
P = []
S = []
for i in range(m):
  a = list(input().split())
  d = int(a[0])
  t = [d, a[1]]
  ps.append(t)
  P.append(d)
  S.append(t[1])
ac = 0
penalty = 0
ans = [0]*100000
for j in range(m):
  if ans[P[j]] <= 0:
    ans[P[j]] -= 1
  if S[j] == 'AC' and ans[P[j]]<0:
    ans[P[j]] *= -1
    ac += 1
for a in ans:
  if a >0:
    penalty += a-1
print(ac, penalty)

Solution (Python):
n, m = list(map(int, input().split()))
ac = [0] * n
wa = [0] * n
numac = 0
numwa = 0
p = 0
for i in range(m):
    _a, _s = list(input().split())
    _a = int(_a)
    if _s == "AC":
        if ac[_a - 1] == 0:
            numac += 1
            ac[_a - 1] = 1
            numwa += wa[_a - 1]
    elif _s == "WA":
        if ac[_a - 1] == 0:
            wa[_a - 1] += 1
print("{} {}".format(numac, numwa))

Solution (Python):
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, m = ril()
ls = rsls(m)

ac = set()
wa = collections.defaultdict(int)
done = set()
for p, s in ls:
    if p not in ac:
        if s == 'AC':
            ac.add(p)
        else:
            wa[p] += 1
print(len(ac), sum(wa[p] for p in ac))

Solution (Python):
n, m = map(int, input().split(" "))
s = []
for i in range(m):
    s.append(tuple(input().split()))
tmp_ac = [0 for _ in range(n+1)]
tmp_pn = [0 for _ in range(n+1)]
end = set()
for i, x in s:
    if x == 'AC':
        if i in end:
            continue
        else:
            tmp_ac[int(i)] += 1
            end.add(i)
    else:
        if i not in end:
            tmp_pn[int(i)] += 1
        else:
            continue
for i in range(n+1):
    if tmp_ac[i] == 0:
        tmp_pn[i] = 0
ac = sum(tmp_ac)
pn = sum(tmp_pn)
print(str(ac) + " " + str(pn))

Solution (Python):
n, m = list(map(int, input().split()))
ps = [input().split() for _ in range(m)]

re = [[] for _ in range(n)]

for p, s in ps:
  p = int(p) - 1
  re[p].append(s)

po = 0
pe = 0

for r in re:
  temp_pe = 0
  for x in r:
    if x == 'AC':
      po += 1
      pe += temp_pe
      break
    else:
      temp_pe += 1

print(po, pe)

Solution (Python):

import sys


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    pe=[0]*N
    ac=[False]*N
    for i in range(M):
        if S[i]=="AC":
            ac[p[i]-1]=True
        if S[i]=="WA" and ac[p[i]-1]==False:
            pe[p[i]-1]+=1

    a=0
    for i in range(N):
        if ac[i]==False: pe[i]=0
        else: a+=1

    print(a, sum(pe))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    p = [int()] * (M)  
    S = [str()] * (M)  
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()