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]*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)

Solution (Python):
n, m = list (map (int, input().split()))
ha = {}
cnt = 0
ans = 0
use = [False for i in range (n + 1)]

for i in range (m) :
    p, s = input().split()
    p = int (p)
    if not use[p] and s == 'AC' :
        cnt += 1
        use[p] = 1;
        ans += ha[p] if p in ha.keys() else 0
        continue
    if use[p] :
        continue
    if not p in ha.keys() :
        ha[p] = 1
    else :
        ha[p] += 1

print (cnt, ans)

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  
def Is(): return map(int, input().split())  
def LI(): return list(map(int, input().split()))  
def TI(): return tuple(map(int, input().split()))  
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  
def LS(): return list(input())  
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, m = Is()
li = [[0]*2 for _ in range(n)]
for _ in range(m):
    p_, s = Ss()
    p = int(p_) - 1
    if s == "AC":
        li[p][0] = 1
    elif s == "WA" and li[p][0] == 0:
        li[p][1] += 1

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

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

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

Solution (Python):


N, M = map(int, input().split())
AC = {}
WA = {}
for _ in range(M):
    p, s = input().split()
    if p not in AC and p not in WA:
        AC[p], WA[p] = 0, 0
    if AC[p] < 1:
        if s == 'AC':
            AC[p] += 1
        elif s == 'WA':
            WA[p] += 1

for p in AC:
    if AC[p] == 0:
        WA[p] = 0

print(sum(AC.values()), sum(WA.values()))

Solution (Python):
n,m = map(int,input().split())
ps = [0] * m
for i in range(m):
    ps[i] = list(map(str,input().split()))
if m == 0:
    print(0,0)
    exit()
countA = [0] * n
countW = [0] * n
cn = 0
for item in ps:
    if item[1] == 'AC' and countA[int(item[0])-1] == 0:
        countA[int(item[0])-1] = 1
        cn += countW[int(item[0])-1]
    else:
        countW[int(item[0])-1] += 1
print(sum(countA),cn)

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

Solution (Python):
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())
    check = [0]*N
    pena = [0]*N
    for _ in range(M):
        p, S = readline().split()
        p = int(p)-1
        if S == 'AC':
            check[p] = 1
        else:
            pena[p] += (not check[p] == 1)*1
    
    ans_ac = sum(check)
    ans_pena = 0
    for i in range(N):
        ans_pena += pena[i] * (check[i] >= 1)
    print(ans_ac, ans_pena)

if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
A=0
W=0
ANS=[[0]*2 for _ in range(n+1)]
for _ in  range(m):
  i,s=input().split()
  if ANS[int(i)][0]==0:
    if s=='AC':
      ANS[int(i)][0]+=1
    else:
      ANS[int(i)][1]+=1
wa=0
for i in ANS:
  if i[0]==1:
    wa+=i[1]
print(sum([row[0] for row in ANS]),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' 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)

Solution (Python):
from collections import defaultdict

N, M = map(int, input().split())
p = [""]*M
S = [""]*M

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

memo_p = defaultdict(int)
memo_s = defaultdict(str)

penalty = 0

for x, y in zip(p, S):
    if memo_s[x]=="AC":
        continue
    elif y=="WA":
        memo_p[x] += 1
    else:
        memo_s[x] = "AC"
        penalty += memo_p[x]
        memo_p[x] = 0

print(sum([i=="AC" for i in memo_s.values()]), penalty)

Solution (Python):
N, M = [int(_) for _ in input().split()]
A = [0 for i in range(N+1)]

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

Solution (Python):


N,M = list(map(int, input().rstrip().split()))
pS_list = []

for i in range(M):
    inp = input().rstrip().split()
    pS_list.append( [int(inp[0]), inp[1]] )


problem_AC_set = set()
problem_WA_dic = {}

for p,S in pS_list:
    if (S == "AC") and (p not in problem_AC_set):
        problem_AC_set.add(p)
    
    if (S == "WA") and (p not in problem_AC_set):
        problem_WA_dic.setdefault(p, 0)
        problem_WA_dic[p] += 1

cnt_AC = len(problem_AC_set)
cnt_WA = sum([v for k,v in problem_WA_dic.items() if k in problem_AC_set])

print(cnt_AC, cnt_WA)

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

Solution (Python):
N, M = map(int, input().split())
P = []
S = []
for i in range(M):
	p, s = input().split()
	P.append(int(p))
	S.append(s)

collect=[0]*N
miss = [0]*N

for a in range(M):
	if S[a] == "AC":
		if collect[P[a]-1] != 1:
			collect[P[a]-1] += 1
	else:
		if collect[P[a]-1] != 1:
			miss[P[a]-1] += 1

AC = sum(collect)
WA = 0
for a in range(N):
	if collect[a] == 1:
		WA += miss[a]


print(AC, WA)

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

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

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    if 'AC' in subs[j]:
        ac += 1
        for k in range(len(subs[j])):
                if subs[j][k] == 'WA':
                    p += 1
                else:
                    break

print(ac, p)

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

mapAC = [False]*(n+1)
countWA = [0]*(n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        mapAC[p] = True
    else:
        countWA[p] += 1*(not mapAC[p])
countWA = map(lambda x, y: x*y, countWA, mapAC)
print(mapAC.count(True), sum(countWA))

Solution (Python):
n,m = map(int,input().split())
num = [0]*m
acwa = [0]*m
for i in range(m):
    num[i], acwa[i] = input().split()
account = 0
wacount = 0
sumi = {}
for i in range(m):
    if num[i] in sumi:
        if sumi[num[i]]!='AC':
            if acwa[i] == 'AC':
                account += 1
                wacount += sumi[num[i]]
                sumi[num[i]]= 'AC'
            else:
                sumi[num[i]] += 1
    else:
        if acwa[i] == 'AC':
            account += 1
            sumi[num[i]]= 'AC'
        else:
            sumi[num[i]]= 1

print(account,wacount)

Solution (Python):
n, m = map(int, input().split())
pss = [list(input().split()) for _ in range(m)]
ac = [0] * n
wa = [0] * n
ans1 = 0
ans2 = 0
for i in range(m):
    if ac[int(pss[i][0]) - 1] == 0:
        if pss[i][1] == 'AC':
            ans1 += 1
            ans2 += wa[int(pss[i][0]) - 1]
            ac[int(pss[i][0]) - 1] = 1
        else:
            wa[int(pss[i][0]) - 1] += 1
    else:
        continue
print(str(ans1) + ' ' + str(ans2))

Solution (Python):
n,m = map(int, input().split())
ac_list = [False]*(n+1)
pena_count = [0]*(n+1)
for i in range(m):
  p, s = input().split()
  p = int(p)
  if not ac_list[p]:
    if s == "AC":
      ac_list[p] = True
    else:
      pena_count[p] += 1
ac_count = 0
pena_c = 0
for i in range(1, n+1):
  if ac_list[i]:
    ac_count += 1
    pena_c += pena_count[i]
print(ac_count, pena_c)

Solution (Python):

n,m=map(int,input().split())
ac=[False]*n
wa=[0]*n

for i in range(m):
    pi,si=list(input().split())
    if si=="AC" and ac[int(pi)-1]==False:
        ac[int(pi)-1]=True
    if si=="WA" and ac[int(pi)-1]==False:
        wa[int(pi)-1]+=1

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

print(accnt,wacnt)

Solution (Python):
n,m = (int(x) for x in input().split())
memo = [0]*n
pena = [0]*n
ans2 = 0
for i in range(m):
    p,s = (str(x) for x in input().split())
    p = int(p)
    if s=="AC":
        memo[p-1] = 1
    elif s=="WA":
        if memo[p-1]==0:
            pena[p-1] += 1

for j in range(n):
    if memo[j]==1:
        ans2 += pena[j]

print("{} {}".format(sum(memo),ans2))

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

ac = [0] * n
wa = [0] * n
wa_total = 0
for _ in range(m):
    tmp_i, s = input().split()
    i = int(tmp_i) - 1
    if ac[i] == 1:
        continue
    if s == 'AC':
        ac[i] = 1
        wa_total += wa[i]
    else:
        wa[i] += 1

print(sum(ac), wa_total)

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

lps = list()

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


lcor = [0] * N
lwrg = [0] * N
for i in range(M):
    if lps[i][1] == "AC":
        if lcor[lps[i][0]-1] == 0:
            lcor[lps[i][0]-1] += 1
    elif lps[i][1] == "WA":
        if lcor[lps[i][0]-1] == 0:
            lwrg[lps[i][0]-1] += 1

for i in range(N):
    if lcor[i] == 0:
        lwrg[i] = 0

print(sum(lcor), sum(lwrg))

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

wa = [0]*n
ac = [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
  if s == "WA":
    if ac[int(p)-1] != 1:
      wa[int(p)-1] += 1
      
sum_ac = sum(ac)
sum_wa = 0
for i in range(n):
  if ac[i] == 1:
    sum_wa += wa[i]
    
print(sum_ac, sum_wa)

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

Solution (Python):
N, M = list(map(int, input().split()))
ac = [0]*N
wrong = [0]*N
ans = 0
for i in range(M):
  temp = input().split()
  if temp[1] == "AC":
    ac[int(temp[0])-1] = 1
  elif ac[int(temp[0])-1] ==0:
    wrong[int(temp[0])-1] += 1

for i in range(N):
  if ac[i]==1:
    ans += wrong[i]
  
print(str(sum(ac)) + " " + str(ans))

Solution (Python):
N,M=map(int,input().split())
ans=['WA' for i in range(N)]
crt=0
mis=0
A=[0 for i in range(N)]
for i in range(M):
    p,S=map(str,input().split())
    if ans[int(p)-1]=='WA':
        if S=='WA':
            A[int(p)-1]+=1
        else:
            crt+=1
            ans[int(p)-1]='AC'
            mis+=A[int(p)-1]
    else:
        continue
print(crt,mis)

Solution (Python):
N,M = map(int,input().split())
dic = {}
ans = 0
for i in range(M):
    p,s = input().split()
    if s == "AC":
        if p in dic:
            ans += dic[p]
        dic[p] = 0
    else:
        if p in dic:
            if dic[p] != 0:
                dic[p] += 1
        else:
            dic[p] = 1

print(len([1 for i in dic.values() if i==0]),ans)

Solution (Python):
N,M =  map(int,input().split())
n = [[] for i in range (N)]
for i in range(M):
  p,S = input().split()
  p = int(p)-1
  n[p].append(S)
ans = 0
ac = 0
for j in n:
  count=0
  for i in j:
    if i=="WA":
      count+=1
    else:
      ans+=count
      ac+=1
      break
print(ac,ans)

Solution (Python):
n,m=map(int,input().split())
probs = [False]*n
wrongs = [0]*n
for i in range(m):
    p,s=map(str,input().split())
    if probs[int(p)-1] == False:
        if s == "AC":
            probs[int(p)-1] = True
        elif s == "WA":
            wrongs[int(p)-1] += 1

ac=0
wa=0
for i,a in enumerate(probs):
    if a == True:
        ac+=1
        wa+=wrongs[i]
print(ac,wa)

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

m = [0]*(N+1)
r = [0]*(N+1)
for i in range(M):
    p,S = input().split()
    p = int(p)
    if r[p] == 0:
        if S == "WA":
            m[p] += 1
        else:
            r[p] = 1
mistake = sum([r[i]*m[i] for i in range(N+1)])
print(sum(r),mistake)

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

penal = [0] * n
check = [0] * n

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

Check = 0
Penal = 0
for i in range(n):
    Check += check[i]
    if check[i] == 1:
        Penal += penal[i]
print(Check, Penal)

Solution (Python):
n,m = map(int,input().split())
ac = [False]*n
count = [0]*n
a=0
b=0
for _ in range(m):
    p,s = input().split()
    if s == 'AC':
        if ac[int(p)-1]==False:
            ac[int(p)-1]=True
            a+=1
            b+=count[int(p)-1]
    else:
        if ac[int(p)-1]==False:
            count[int(p)-1]+=1
            
print(str(a)+' '+str(b))

Solution (Python):
n,m=map(int,input().split())
AC=[0]*n
penalty1=[0]*n 
penalty2=[0]*n 

for _ in range(m):
    P,S=map(str,input().split()) 
    p=int(P)-1
    if AC[p]==1:
        continue 
    else:
        if S=="AC":
            AC[p]=1 
            penalty2[p]=penalty1[p]
        else:
            penalty1[p]+=1 
            
print(sum(AC),sum(penalty2))

Solution (Python):
def main():
    N, M = list(map(int, input().split(' ')))
    accepted = [0 for _ in range(N)]
    wa_count = [0 for _ in range(N)]
    for _ in range(M):
        p, S = input().split(' ')
        p = int(p) - 1
        if accepted[p] == 1:
            continue
        
        if S == 'WA':
            wa_count[p] += 1
        else:
            accepted[p] = 1
    score = sum(accepted)
    penalty = sum([is_ac * wa for is_ac, wa in zip(accepted, wa_count)])
    print('{} {}'.format(score, penalty))


if __name__ == '__main__':
    main()

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

no = [0] * (N + 1)
ok = 0
x = 0
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and no[p] != -1:
        ok += 1
        x += no[p]
        no[p] = -1
    elif s == 'WA' and no[p] != -1:
        no[p] += 1

print(ok, x)

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

d = [False for _ in range(n)]
w = 0
a = 0
for i in range(m):
    P,S = input().split()
    P = int(P)
    if(S == 'WA'):
        if(d[P-1] >= 0):d[P-1] += 1
    elif(S == 'AC'):
        if(d[P-1] >= 0):
            a += 1
            w += d[P-1]
            d[P-1] = -1

print(a,w)

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

for j in range(N):
    if A[j] == 0:
        W[j] =0
print(sum(A),sum(W))

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


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



ac_num = [0] * n
wa_num = [0] * n

for i in range(m):
    if s[i] == "AC":
        ac_num[p[i]-1] = 1
    elif s[i] == "WA":
        if ac_num[p[i]-1] == 0:
            wa_num[p[i]-1] += 1

for i in range(n):
    if ac_num[i] == 0:
        wa_num[i] = 0


print(sum(ac_num),sum(wa_num))

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

for _ in range(m):
    p,s = input().split()
    p = int(p) - 1
    if s == 'WA':
        if li[p] != 'AC':
            li[p] = 'WA'
            wa[p] += 1
    else:
        if li[p] != 'AC':
            li[p] = 'AC'
            ac[p] += 1

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

print(sum(ac),wa1)

Solution (Python):
n, m = map(int, input().split())
c = {}
for i in range(n):
    c[i] = 0
ac = [False] * n
acn = 0
for _ in range(m):
    p,s = tuple(input().split())
    p = int(p)
    if s == 'AC' and ac[p-1]==False:
        ac[p-1] = True
        acn+=1
    elif s== 'WA' and ac[p-1]==False:
        c[p-1]+=1
pen = 0
for i,p in c.items():
    if ac[i]: pen+=p
print(acn, pen, sep=' ')

Solution (Python):
N,M=map(int,input().split())
words=[[] for _ in range(N)]
for _ in range(M):
    p,S=input().split()
    p=int(p)-1
    words[p].append(S)
AC=0
WA=0
for a in words:
    if a.count('WA') != 0 and len(a) == a.count('WA'):
        continue
    for b in a:
        if b=='AC':
            AC+=1
            break
        elif b=='WA':
            WA+=1
print(AC,WA)

Solution (Python):

def solve(N,M,P,S):
    counterAC = 0
    counterWA = 0
    dic = {key:"WA" for key in set(P)}
    counter = {key:0 for key in set(P)}
    for p,s in zip(P,S):
        if(dic[p] == "AC"):
            continue
        else:
            if(s == "AC"):
                counterAC += 1
                counterWA += counter[p]
                dic[p] = "AC"
            else:
                counter[p]+=1
    print(counterAC,counterWA)
def main():
    N,M = map(int,input().split())
    P = []
    S = []
    for _ in range(M):
        p,s=map(str,input().split())
        P.append(int(p))
        S.append(s)
    solve(N,M,P,S)
    

if __name__ == "__main__":
    main()

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 = [0]*n
wa = [0]*n

ans_count = 0
penalty_count = 0

for i in range(m):
    if s[i] == "AC":
        ac[p[i]-1] += 1
        if ac[p[i]-1] == 1:
            ans_count += 1
            penalty_count += wa[p[i]-1]
    else:
        wa[p[i]-1] += 1

print(ans_count, penalty_count)

Solution (Python):

n, m = map(int, input().split())
probrem = [0] * n
warn = [0] * n
for i in range(m):
    a, b = map(str, input().split())
    a=int(a)
    if probrem[a - 1] == 0 and b == 'AC':
        probrem[a - 1] = 1
    if probrem[a - 1] == 0 and b == "WA":
        warn[a - 1] += 1

for i in range(n):
    if probrem[i] == 0:
        warn[i] = 0
print(sum(probrem),sum(warn))

Solution (Python):
_, M = map(int, input().split())
PS = [tuple(input().split()) for _ in range(M)]
result = dict()
AC, WA = 0, 0
for p,s in PS:
    i = int(p)
    if not (i in result):
        if s == "WA":
            result[i] = 1
        elif s == "AC":
            AC += 1
            result [i] = "AC"
    else:
        if result[i] != "AC":
            if s == "WA":
                result[i] += 1
            if s == "AC":
                AC += 1
                WA += result[i]
                result[i] = s
print(AC, WA)

Solution (Python):
n,m=map(int,input().split())
ps_input=[[int(j) if n==0 else j for n,j in enumerate(input().split())]for i in range(m)]

ac_count = [0]*n
penalty= [0]*n
for ps in ps_input:
    if ps[1]=='AC':
        if ac_count[ps[0]-1]==0:
            ac_count[ps[0]-1]=1
    if ps[1]=='WA':
        if ac_count[ps[0]-1]==1:
            continue
        penalty[ps[0]-1]+=1
ans_ac=0
ans_penalty=0
for a,p in zip(ac_count,penalty):
    if a==1:
        ans_ac+=1
        ans_penalty+=p
print(ans_ac,ans_penalty)

Solution (Python):
N, M = map(int, input().split())
ac = 0
wa = 0
mp = [0]*N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == "AC":
        if mp[p] != "AC":
            ac += 1
            wa += mp[p]
            mp[p] = "AC"
    else:
        if mp[p] != "AC":
            mp[p] += 1
print(ac, wa)

Solution (Python):
def solve():
    N, M = map(int, input().split())
    ac, wa= 0, 0

    mp = [0] * N
    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if s == "AC":
            if mp[p] != -1:
                ac += 1
                wa += mp[p]
                mp[p] = -1
        else:
            if mp[p] != -1:
                mp[p] += 1
    return ac, wa

print(*solve())

Solution (Python):
n, m = map(int, input().split())
ac_list = [0]*n
wa_list = [0]*n
AC = 0
WA = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac_list[p] == 0:
        if s == "WA":
            wa_list[p] += 1
        else:
            ac_list[p] = 1
            AC += ac_list[p]
            WA += wa_list[p]


print(AC, WA)

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

Solution (Python):
n,m=map(int,input().split())
p=[]
l=[1]*n
for i in range(m):
    P=list(input().split())
    p.append(P)

AC=0
WA=0

x=[0]*n

for i in range(m):
    if l[int(p[i][0])-1]==1:
        if p[i][1]=="WA":
            WA+=1
            x[int(p[i][0])-1]+=1
        else:
            AC+=1
            l[int(p[i][0])-1]=0

for i in range(n):
    if l[i]==1:
        WA-=x[i]

print(AC,WA)

Solution (Python):
from collections import defaultdict 

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

N, M = multi_input()
pS = [input().split() for _ in range(M)]

l = ['WA' for _ in range(N+1)]
d = defaultdict(int)
a = 0
for i, j in pS:
    i = int(i)
    if l[i] == 'WA':
        if j == 'WA':
            d[i] += 1
        else:
            a += 1
            l[i] = 'AC'

p = 0
for key, value in d.items():
    if l[key] == 'AC':
        p += value
           
print(a, p)

Solution (Python):
n,m=map(int,input().split())
a=[input().split() for i in range(m)]
b=[0]*n
c=[0]*n
for j in range(m):
    if a[j][1]=="AC":
        b[int(a[j][0])-1]=1
    else:
        if b[int(a[j][0])-1]==0:
            c[int(a[j][0])-1]+=1

for k in range(n):
    if b[k]!=1:
        c[k]-=c[k]
print(str(sum(b)),str(sum(c)))

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

AC_number = [0 for i in range(N)] 
WA_number = [0 for i in range(N)] 
for i in range(M):
    
    if submits[i][1] != 'AC' and AC_number[submits[i][0] - 1] != 1:
        WA_number[submits[i][0] - 1] += 1
    
    
    if submits[i][1] == 'AC':
        AC_number[submits[i][0] - 1] = 1

AC_count = 0
WA_count = 0
for i in range(N):
    if AC_number[i] == 1:
        AC_count += 1
        WA_count += WA_number[i]
print(AC_count, WA_count)

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

AC_number = [0 for i in range(N)] 
WA_number = [0 for i in range(N)] 
for i in range(M):
     
    if submits[i][1] == 'AC':
        AC_number[submits[i][0] - 1] = 1
    
    elif AC_number[submits[i][0] - 1] == 0:
        WA_number[submits[i][0] - 1] += 1

AC_count = 0
WA_count = 0
for i in range(N):
    if AC_number[i] == 1:
        AC_count += 1
        WA_count += WA_number[i]
print(AC_count, WA_count)

Solution (Python):
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
    if ps[i][1]=="AC":
        rig[int(ps[i][0])-1]=1
    else:
        if rig[int(ps[i][0])-1]==0:
            pen[int(ps[i][0])-1]+=1
cnt1,cnt2=0,0
for i in range(n):
    if rig[i]==1:
        cnt1+=rig[i]
        cnt2+=pen[i]

print(str(cnt1)+" "+str(cnt2))

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

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

    ac = [False] * N
    wa = [0] * N
    for _ in range(M):
        it = iter(input().split())
        p = int(next(it)) - 1
        s = next(it)
        if s == 'AC':
            ac[p] = True
        else:
            if not ac[p]:
                wa[p] += 1
    print(ac.count(True), sum(w for p, w in enumerate(wa) if ac[p]))


if __name__ == '__main__':
    main()

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

x=[int(l) for l in x]


ac=0
wa=0
aclist=[0]*n
walist=[0]*n
p=[0]*n

for i in range(m):
  if y[i]=='AC' and p[x[i]-1]==0:
    aclist[x[i]-1]+=1
    p[x[i]-1]=1
  elif y[i]=='WA' and p[x[i]-1]==0:
    walist[x[i]-1]+=1

for j in range(n):
  if 1==aclist[j]:
    ac+=1
    wa+=walist[j]
print(ac,wa)

Solution (Python):
n, m = map(int, input().split())
ac = set()
wa = 0
wa_stock = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and not p in ac:
        ac.add(p)
        wa += wa_stock[p]
    elif not p in ac:
        wa_stock[p] += 1
print(len(ac), wa)

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

Solution (Python):
n,m = map(int,input().split())
wa = [0 for _ in range(n+1)]
ac = 0
q = [False for _ in range(n+1)]

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s =="WA":
        if q[p]:
            continue
        else:
            wa[p] += 1
    else:
        if q[p]:
            continue
        else:
            q[p] = True
            ac += 1
p = 0
for i,j in zip(q,wa):
    if i:
        p += j
print(ac,p)

Solution (Python):
from collections import deque
def solve():
    solved = set()

    N,M = map(int, input().split())
    wa = [0]*(N+1)
    pn = 0
    for i in range(M):
        p,s = input().split()

        if s == "AC":
            if not (p in solved):
                solved.add(p)
                pn += wa[int(p)]
        else:
            if not (p in solved):
                wa[int(p)] += 1
    print(len(solved), pn)



if __name__ == '__main__':
    solve()

Solution (Python):
n,m=map(int,input().split())
ac,wa=0,0
ac_set=set()
wa_cnt=[0]*(n+1)
for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if s=="AC":
    if p in ac_set:
      continue
    ac_set.add(p)
  else:
    if p in ac_set:
      continue
    wa_cnt[p]+=1
ac=len(ac_set)
for a in ac_set:
  wa+=wa_cnt[a]
print(ac,wa)

Solution (Python):
N,M=map(int, input().split())
now=[0]*N
pena=0
for i in range(M):
    num,result=input().split()
    num=int(num)-1
    if result=="AC":
        if now[num]>0:
            pena+=now[num]
        now[num]=-1
    else:
        if now[num]>=0:
            now[num]+=1
print(now.count(-1), pena)

Solution (Python):
N,M = map(int,input().split())
pro = [0 for i in range(N+1)]
ac,wa = 0,0
for i in range(M):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        if pro[p] != -1:
            ac += 1
            wa += pro[p]
            pro[p] = -1
    else:
        if pro[p] != -1:
            pro[p] += 1
print(ac,wa)

Solution (Python):
n, m = map(int, input().split())
ps = []
for _ in range(m):
    p, s = input().split()
    ps.append((int(p), s))
was = [0]*(n+1)
total_ac = 0
total_wa = 0
for p, s in ps:
    if was[p]<0:
        continue
    if s=='AC':
        total_wa += was[p]
        total_ac += 1
        was[p] = -1
    else:
        was[p] += 1
print(total_ac, total_wa)

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

AC={}
WA={}
pe=0
ac=0

for i in range(M):
    p,S=map(str,input().split())
    if S=="AC":
        if p in AC.keys():
            pass
        else:
            AC[p]=1
            if p in WA.keys():
                pe+=WA[p]
            ac+=1
    else:
        if p in WA.keys():
            WA[p]+=1
        else:
            WA[p]=1
print(ac,pe)

Solution (Python):
N,M = map(int,input().split())
C = {i:[0,0] for i in range(1,N+1)}
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if C[p][0]==0 and S=="WA":
        C[p][1] += 1
    elif C[p][0]==0 and S=="AC":
        C[p][0] = 1
numA = 0
numB = 0
for i in range(1,N+1):
    numA += C[i][0]
    if C[i][0]==1:
        numB += C[i][1]
print(numA,numB)

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

def resolve():
    N,M=pin()
    ps=[tupin(str) for _ in range(M)]

    WA=[0]*N
    AC=[0]*N
    for m in range(M):
        p,s=ps[m]
        p=int(p)-1
        if AC[p]==0:
            if s=="WA": 
                WA[p]+=1
            else:
                AC[p]=1
    wa=0
    for Wa in range(N):
        if AC[Wa]==1:wa+=WA[Wa]
    print(sum(AC),wa)
        

resolve()