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 = map(int, input().split())

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

Solution (Python):



def main():
    N, M = map(int, input().split())
    ans = [0, 0]
    A = [[0, 0] for _ in range(N)]

    for i in range(M):
        p, s = input().split()
        p = int(p)
        if s == 'AC':
            A[p - 1][1] = 1
        elif A[p - 1][1] == 0:
            A[p - 1][0] += 1
    
    for i, j in A:
        if j == 1:
            ans[0] += 1
            ans[1] += i

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

if __name__ == "__main__":
    main()

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

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

Solution (Python):

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

    score = [0] * (N + 1)
    ac = [False] * (N + 1)
    for p, S in pS:
        res = int(p)
        if S == 'AC':
            ac[res] = True
        if ac[res]:
            continue
        score[res] += 1
    penalty = 0
    for i in range(N + 1):
        if ac[i]:
            penalty += score[i]
    print(sum(ac), penalty)
    
    


if __name__ == '__main__':
    main()

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

Solution (Python):
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt, wa_cnt_ls = 0, [ 0 for i in range(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)

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

submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)

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

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

for i in range(n + 1):
    if ac[i] != 1:
        wa[i] = 0

print(sum(ac), sum(wa))

Solution (Python):
n,m = map(int,input().split())
AC = [0]*n
WA = [0]*n
ac = 0
wa = 0

for i in range(m):
  c,s = input().split()
  c = int(c)
  c -= 1
  if AC[c]: continue
  if s == 'AC':
    AC[c] = 1
  else:
    WA[c] +=  1

for i in range(n):
  ac += AC[i]
  if AC[i]: 
    wa += WA[i]

print(ac, wa)

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

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

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

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

Solution (Python):
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt, wa_cnt_ls = 0, [ 0 for i in range(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)

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

Solution (Python):
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls, wa_cnt = [ 0 for i in range(N) ], 0
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)

Solution (Python):
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
ps=[input().split() for i in range(m)]

dic={}
anslst=[0]*n
for i in range(m):
    p,s=ps[i]
    if s=="AC":
        dic[p]=1
    else:
        if p in dic:
            continue
        else:
            anslst[int(p)-1]+=1


ans=0
for i in dic.keys():
    ans+=anslst[int(i)-1]
print(len(dic),ans)

Solution (Python):
N, M = map(int, input().split())
S = [[0 for j in range(2)] for i in range(M)]
for i in range(M):
  X = input().split()
  S[i][0] = int(X[0])
  S[i][1] = str(X[1])
A = [0] * N
p = 0
s = 0
for i in range(M):
  if S[i][1] == "WA":
    if A[S[i][0]-1] != "x": 
      A[S[i][0]-1] += 1
  if S[i][1] == "AC":
    if A[S[i][0]-1] != "x":
      p +=  A[S[i][0]-1]
      A[S[i][0]-1] = "x"
      s += 1
arr = [s, p]
print(*arr)

Solution (Python):
import math , sys

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

cor = 0
pen = 0

F = [False]*N
C = [0]*N

for i in range(M):
    A , B = list( input().split() )
    A = int(A)-1

    if B == "WA" and not F[A]:
        C[A]+=1

    

    if B == "AC" and not F[A]:
        F[A] = True
        cor += 1
        pen +=C[A]
print(cor,pen)

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

	else:
		if 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])

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

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

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

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

Solution (Python):
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls, wa_cnt = [0] * N, 0

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)

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

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

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

Solution (Python):
n, m = map(int,input().split())
lst = [[0, 0] for i in range(n)]
for i in range(m):
    p, s = map(str,input().split())
    p = int(p) - 1
    if (lst[p][0] == 0):
        if (s == "AC"):
            lst[p][0] = 1
        else:
            lst[p][1] = lst[p][1] + 1

ans = 0
pena = 0
for i in range(n):
    if (lst[i][0] == 1):
        ans = ans + 1
        pena = pena + lst[i][1]

print(ans, pena)

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

Solution (Python):
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
    else:
        if AC[A] == 0:
            AC[A] = 1

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

Solution (Python):

n,m = map(int,input().split())
submit = []
check = [0] * n

for x in range(m):
    a,b = input().split()
    a = int(a)
    x = [a,b]
    submit.append(x)

o = 0
x = 0


for y in submit:
    if check[y[0]-1] == 0:
        if y[1] == "AC":
            o += 1
            check[y[0]-1] = 1
        elif y[1] == "WA":
            x += 1

for z in submit:
    if check[z[0]-1] == 0:
        if z[1] == "WA":
            x -= 1


print(o,x)

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

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

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



ACs = [False for _ in range(N)]
WAs = [0 for _ in range(N)]

for pS in pSs:
    problem = int(pS[0]) -1
    answer = pS[1]
    if ACs[problem] == True:
        continue
    else:
        if answer == "WA":
            WAs[problem] += 1
        else:
            ACs[problem] = True

num_WA = 0
for i, WA in enumerate(WAs):
    if ACs[i] == True:
        num_WA += WA

print(sum(ACs), num_WA)

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

Solution (Python):
n,m=map(int,input().split())
l = [list(input().split()) for i in range(m)]
ans=[0]*n
for i in range(m):
    if l[i][1]=="AC":
        if ans[int(l[i][0])-1]==0:
            ans[int(l[i][0])-1]+=0.5
        if ans[int(l[i][0])-1]<0:
            ans[int(l[i][0])-1]=ans[int(l[i][0])-1]*(-1)
    else:
        if ans[int(l[i][0])-1]<=0:
            ans[int(l[i][0])-1]-=1
ac=0
wa=0
for i in range(n):
    if ans[i]>0:
        ac+=1
        if ans[i]!=0.5:
          wa+=ans[i]
print(ac,wa)

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


def main():
    N, M = map(int, input().split())
    passed = set([])
    penalty = defaultdict(int)
    for _ in range(M):
        p, S = input().split()
        if S == "WA" and p not in passed:
            penalty[p] += 1
        elif S == "AC":
            passed.add(p)
    ans = sum([penalty[p] for p in passed])
    print(len(passed), ans)


if __name__ == '__main__':
    main()

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

Solution (Python):

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

def main():
    mod=10**9+7
    N,M=MI()
    AC=[0]*N
    WA=[0]*N
    
    for _ in range(M):
        p,s=input().split()
        p=int(p)-1
        if s=="AC":
            AC[p]=1
        else:
            if AC[p]==0:
                WA[p]+=1
       
    acs=sum(AC)     
    was=0
    for i in range(N):
        was+=AC[i]*WA[i]
        
    print(acs,was)
        

main()

Solution (Python):

import sys
from itertools import chain







def solve(N: int, M: int, P: "List[int]", S: "List[str]"):
    ac = [0] * N
    wa = [0] * N
    for p, s in zip(P, S):
        if s == "AC":
            ac[p - 1] = 1
        else:  
            if ac[p - 1] == 0:
                wa[p - 1] += 1
    for i in range(N):
        if ac[i] == 0:
            wa[i] = 0

    return sum(ac), sum(wa)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    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)
    a1, a2 = solve(N, M, P, S)
    print(a1, a2)


if __name__ == "__main__":
    main()

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

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

Solution (Python):




def resolve():
    import sys
    input = sys.stdin.readline

    n, m = [int(x) for x in input().rstrip().split(" ")]

    ac = [False for _ in range(n)]
    wa = [0 for _ in range(n)]
    wa_sum = 0

    for i in range(m):
        p, s = input().rstrip().split(" ")
        p = int(p) - 1
        if ac[p]:
            continue
        if s == "WA":
            wa[p] += 1
        else:
            ac[p] = True
            wa_sum += wa[p]
    print(len([x for x in ac if x]), wa_sum)


if __name__ == "__main__":
    resolve()

Solution (Python):
N, M = list(map(int, input().split()))
WA = [0]*N
AC = [False]*N
for _ in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'WA':
        if AC[p] == False:
            WA[p] += 1
    else:
        AC[p] = True

ans = [0, 0]
for i in range(N):
    if AC[i] == False:
        continue
    ans[0] += 1
    ans[1] += WA[i]

print(*ans)

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

Solution (Python):
n, m = 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}')

Solution (Python):
n,m = map(int,input().split())
sub = []
for i in range(m):
    tmp= [x for x in input().split()]
    sub.append(tmp)
ac = [0]*n
wa = [0]*n
for i in range(m):
    res = sub[i][1]
    que = int(sub[i][0]) - 1
    if res == "AC" and ac[que] == 0:
        ac[que] += 1
    elif res == "WA" and ac[que] == 0:
        wa[que] += 1
for i in range(n):
    if ac[i] != 1:
        wa[i] = 0
print(sum(ac),sum(wa))

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

Solution (Python):
n, m = 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}')

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

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

Solution (Python):

"""
Created on Tue Sep  8 16:23:28 2020

@author: liang
"""

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
    else:
        if 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)

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

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

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

flag = dict()
for i in range(m):
  q, s = input().split()
  if q not in flag:
    flag[q] = [0,0]
    if s == "AC":
      flag[q][0] += 1
    else:
      flag[q][1] += 1
  else:
    if flag[q][0] != 1:
      if s == "AC":
        flag[q][0] += 1
      else:
        flag[q][1] += 1
      
ans = [0,0]
for v in flag.values():
  if v[0]:
    ans[0] += 1
    ans[1] += v[1]

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

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
def solve():
    N, M = [int(i) for i in input().split()]
    ans = set()
    pen = 0
    arr = [0] * N
    for _ in range(M):
        p, s = input().split()
        if s == 'AC' and int(p) not in ans:
            ans.add(int(p))
            pen += arr[int(p) - 1]
        if s == 'WA':
            arr[int(p) - 1] += 1
    print(f'{len(ans)} {pen}')

if __name__ == "__main__":
    solve()

Solution (Python):
n,m = map(int,input().split())
acli = [0]*n
wali = [0]*n
acsi = 0
wasi = 0
for i in range(m):
    p,s = map(str,input().split())
    if acli[int(p)-1] == 0:
        if s == 'AC':
            acli[int(p)-1] = 1
            acsi += 1
        elif s == 'WA':
            wali[int(p)-1] += 1
for j in range(n):
    if acli[j] == 1 and wali[j] != 0:
        wasi += wali[j]
print(acsi,wasi)

Solution (Python):
n, m = map(int, input().split())
flg = [0]*n
ac = 0
pe = [0]*n

for i in range(m):
    p, s = input().split()
    if flg[int(p)-1] == 0:
        if s == "WA":
            pe[int(p)-1] += 1
        else:
            flg[int(p)-1] = 1
            ac += 1
spe = 0
for i in range(n):
    if flg[i] == 1:
        spe += pe[i]

print(ac, spe)

Solution (Python):
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
    else:
        if p not in ac:
            wa[p] += 1
print(len(ac), sum([wa[x] for x in ac.keys()]))

Solution (Python):
n,m = map(int,input().split())
f = [False for i in range(n)]
ac = 0
wa = [0 for i in range(n)]
for i in range(m):
  p,s = input().split()
  p = int(p) - 1
  if not f[p]:
    if s == "WA":
      wa[p] += 1
    else:
      f[p] = True
      ac += 1
w = 0
for e,c in zip(f,wa):
  if e:
    w += c
print(ac,w)

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

dac = {}
for i in range(1,n+1):
    dac[str(i)] = 0
dwa = {}
for i in range(1,n+1):
    dwa[str(i)] = 0

for i in range(m):
    p,s = input().split()
    if s == 'AC':
        dac[p] = 1
    if s == 'WA' and dac[p] == 0:
        dwa[p] += 1

ac = 0
wa = 0

for k,v in dac.items():
    ac += v

for k,v in dwa.items():
    if dac[k] == 1:
        wa += v

print(ac,wa)

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

Solution (Python):
N, M = map(int,input().split())
results = [0 for _ in range(N+1)]
wa_list = [0 for __ in range(N+1)]
ac_cnt = 0
wa_cnt = 0
for _ in range(M):
  problem, result = input().split()
  if results[int(problem)] == 0 and result == 'AC':
    ac_cnt += 1
    results[int(problem)] = 1
  elif results[int(problem)] == 0 and result == 'WA':
    wa_list[int(problem)] += 1
for i in range(1, N+1):
  if results[i] == 1:
    wa_cnt += wa_list[i]
print(ac_cnt, wa_cnt)

Solution (Python):




import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())

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

    for i in range(m):
        p,s=readline().rstrip().split()
        p=int(p)-1
        if s=="AC":
            ac[p]=1
            continue
        if ac[p]==0:
            wa[p]+=1
    for i in range(n):
        wa[i]*=ac[i]
    
    print(sum(ac),sum(wa))

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Solution (Python):

n, m = map(int, input().split())
ck = set()
pe = 0
ac = 0
penalty = 0
cp = [0] * (n+1)
for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in ck:
        continue

    if s == 'WA':
        cp[p] += 1
    else:
        penalty += cp[p]
        pe = 0
        ac += 1
        ck.add(p)

print(ac, penalty)

Solution (Python):
from collections import defaultdict as dic
n, m = map(int, input().split())
ac = 0
pena = 0
d = dic(list)
for i in range(m):
    pi, si = input().split()
    d[pi].append(si)

for (k, v) in d.items():
    pe = 0
    flag = False
    for aw in v:
        if aw == 'WA':
            pe += 1
        else:
            ac += 1
            flag = True
            break

    if flag:
        pena += pe

print(ac, pena)

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

Solution (Python):
N, M = map(int, input().split())
accept = set()
penalty = 0
wa_cnt = [0] * N

for m in range(M):
    p, s = input().split()
    p = int(p) -1 
    if p in accept:
        continue
    elif s == 'AC':
        accept.add(p)
        penalty += wa_cnt[p]
    else:
        wa_cnt[p] += 1

print(len(accept), penalty)

Solution (Python):
N, M = map(int, input().split())
accepted = set()
penalty = 0
wa_cnt =  [0]*N

for m in range(M):
    p,s = input().split()
    p = int(p) - 1
    if p in accepted:
        continue
    elif s == 'AC':
        accepted.add(p)
        penalty += wa_cnt[p]
    else:
        wa_cnt[p] += 1
print(len(accepted), penalty)

Solution (Python):
N, M = map(int, input().split())
accepted = set()
penalty = 0
wa_cnt =  [0]*N

for m in range(M):
    p,s = input().split()
    p = int(p) - 1
    if p in accepted:
        continue
    if s == 'AC':
        accepted.add(p)
        penalty += wa_cnt[p]
    else:
        wa_cnt[p] += 1
print(len(accepted), penalty)

Solution (Python):
N,M = (int(x) for x in input().split())
AC = [False]*N
WA_count = [0]*N
AC_count = 0
for i in range(M):
  p,S = (y for y in input().split())
  if AC[int(p)-1] == False:
    if S == 'AC':
      AC[int(p)-1] = True
      AC_count += 1
    else:
      WA_count[int(p)-1] += 1
for i in range(N):
  if AC[i] == False:
    WA_count[i] = 0
print(AC_count,sum(WA_count))

Solution (Python):
N, M = map(int, input().split())
countlis = [0] * (N+1)
penalty = 0
clear = 0
checkset = set()
for i in range(1,M+1):
    p,s = input().split()
    p = int(p)
    if p in checkset:
        continue
    if s == "WA":
        countlis[p] += 1
    elif s == "AC":
        penalty += countlis[p]
        clear += 1
        checkset.add(p)

print("{0} {1}".format(clear, penalty))