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):
import itertools





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




aced = {}
waed = [0] * (N + 1)

cnt_ac = 0
for i in range(M):
    p_i, S_i = input().split()
    if S_i == 'WA':
        if not p_i in aced:
            waed[int(p_i)] += 1
    else:
        if not p_i in aced:
            cnt_ac += 1
            aced[p_i] = 1

cnt_pena = 0
for k in aced:
    cnt_pena += waed[int(k)]

print(cnt_ac, cnt_pena)

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

AC = [0]*N
WA = [0]*N
AC_cnt = 0
WA_cnt = 0

p = [0]*M
S = [0]*M

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

for i in range(M):
    q_num = int(p[i])
    if AC[q_num-1] == 0:
        if S[i] == "AC":
            AC[q_num-1] = 1
        else:
            WA[q_num-1] += 1

for i in range(N):
    if AC[i] == 1:
        WA_cnt += WA[i]
        AC_cnt += 1

print(AC_cnt,WA_cnt)

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

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

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

r1 = sum(ac)
r2 = sum(wa[i] if ac[i] else 0 for i in range(n))

print(r1, r2)

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


def main():
  N, M = list(map(int, input().split()))
  PS = []
  for i in range(M):
    p, s = input().split()
    PS.append((int(p)-1, s))

  penas = [0]*(N)
  is_ac = [0]*(N)
  for i in range(M):
    p, s = PS[i]
    if s == 'AC':
      is_ac[p] = True
    elif not is_ac[p]:
      penas[p] += 1

  num_ac = sum(is_ac)
  num_pe = 0

  for i in range(N):
    if is_ac[i]:
      num_pe += penas[i]

  print(num_ac, num_pe)


if(__name__ == '__main__'):
  main()

Solution (Python):
n,m = list(map(int,input().split()))
ans = [0,0]
p_list = [0]*(n+1)
ac = [0]*(n+1)
for i in range(m):
    ps = input().split()
    p = int(ps[0])
    s = ps[1]
    if s=='AC' and ac[p]==0:
        ans[0] += 1
        ans[1] += p_list[p]
        ac[p] += 1
    else:
        if ac[p]==0:
            p_list[p] += 1
print(*ans, sep=' ')

Solution (Python):
n,m = map(int,input().split())
if m != 0:
    l = [list(input().split()) for i in range(m)]
    p,s = [list(i) for i in zip(*l)]
t = [0] * n
ac = 0
wa = 0

for i in range(m):
    if s[i] == 'WA' and t[int(p[i])-1] != 'AC':
        t[int(p[i])-1] += 1
    elif s[i] == 'AC' and t[int(p[i])-1] != 'AC':
        ac += 1
        wa += t[int(p[i])-1]
        t[int(p[i])-1] = 'AC'

print(ac,wa)

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=input().split()
   if s=='AC':
        AC[int(p)]=1
   elif s=='WA' and AC[int(p)]==0:
        WA[int(p)] +=1
        
ACn=np.array(AC)
WAp=np.array(WA)

print(sum(AC),sum(ACn*WAp))

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

ans_num = [0]*(N+1)
ans_pe = [0]*(N+1)

for i in range(M):
  result = t_ans[i][1]
  question = int(t_ans[i][0])
  if result == 'AC' and ans_num[question] == 0:
    ans_num[question] = 1
  elif result == 'WA' and ans_num[question] == 0:
    ans_pe[question] += 1

for i in range(N+1):
  if ans_num[i] != 1:
    ans_pe[i] = 0

print(f'{sum(ans_num)} {sum(ans_pe)}')

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, m = MI()
    ac = [False]*(n+1)
    wa = [0]*(n+1)
    for _ in range(m):
        temp = input().split()
        p, s = int(temp[0]), temp[1]
        if not ac[p]:
            if s == 'AC':
                ac[p] = True
            else:
                wa[p] += 1
    penalty = 0
    for i in range(n+1):
        if ac[i]:
            penalty += wa[i]
    print('{} {}'.format(sum(ac), penalty))

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

def solve():
    dp = np.zeros((2, N+1))

    ac = 0
    wa = 0
    for i in range(M): 
        if (dp[0][S[i][0]] == 0):
            if(S[i][1] == "WA"):
                dp[1][S[i][0]] += 1
            elif(S[i][1] == "AC"):
                ac += 1
                dp[0][S[i][0]] = 1
                wa += dp[1][S[i][0]]
    print(ac, int(wa))

if __name__=="__main__":

    N, M = list(map(int, input().split()))
    S = []
    for i in range(M):
        a,b = input().split()
        S.append([int(a), b])

    solve()

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

print(sum(ac), sum([w*a for w,a in zip(wa, ac)]))

Solution (Python):
def main():
    n, m = map(int, input().split())
    P = [0] * m
    S = [0] * m
    for i in range(m):
        P[i], S[i] = map(str , input().split())
    
    
    WA = [0] * (n+1)
    
    AC = [False] * (n+1)
    wa = 0
    for i in range(m):
        p = int(P[i])
        if AC[p]:
            continue
        else:
            if S[i] == 'WA':
                WA[p] += 1
            else:
                AC[p] = True
                wa += WA[p]
    
    
    ac = sum(AC)
    print(ac, wa)
        
if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    P = [0] * m
    S = [0] * m
    for i in range(m):
        P[i], S[i] = map(str , input().split())
    
    
    WA = [0] * (n+1)
    
    AC = [False] * (n+1)
    cnt = 0
    for i in range(m):
        p = int(P[i])
        if AC[p]:
            continue
        else:
            if S[i] == 'WA':
                WA[p] += 1
            else:
                AC[p] = True
                cnt += WA[p]
    
    ac = sum(AC)
    print(ac, cnt)
        
if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)

from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque


def main():
    num, submit = map(int, input().split())
    fin_flg = [0 for i in range(num + 1)]
    count_ac, count_wa = 0, 0

    for i in range(submit):
        a, b = input().split()
        a = int(a)
        if fin_flg[a] == -1:
            continue
        if b == "AC":
            count_ac += 1
            count_wa += fin_flg[a]
            fin_flg[a] = -1
        else:
            fin_flg[a] += 1

    print(count_ac, count_wa)




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]=map(str,input().split())
cor=[0]*n
fal=[0]*n
for i in range(m):
  x=int(p[i])
  if cor[x-1]==0:
    if s[i]=='AC':
      cor[x-1]=1
    else:
      fal[x-1]+=1
ans_cor=0
ans_fal=0
for i in range(n):
  if cor[i]==1:
    ans_cor+=1
    ans_fal+=fal[i]
print(ans_cor,ans_fal)

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

Solution (Python):
N, M = map(int,input().split())
accepted = [0]*N
wrong_ans =[0]*N 
for i in range(M):
    p,s = input().split()
    p = int(p)-1
    if s =="AC":
        accepted[p] = 1
    elif s == "WA" and accepted[p]==0:
        wrong_ans[p] = wrong_ans[p]+1

AC = 0
penalty = 0
for i in range(N):
    if accepted[i] == 1:
        AC = AC+1
        if wrong_ans[i]>=1:
            penalty = penalty+wrong_ans[i]
print(AC,penalty)

Solution (Python):
n, m = map(int, input().split())
point = 0 ; penalty = 0
false = [0] * n
correct = [0] * n
for i in range(m) :
    p, s = input().split()
    p = int(p)
    if s == "WA" and correct[p-1] != 1 :
        false[p-1] += 1
    if s == "AC" :
        correct[p-1] = 1

for i in range(n) :
    if false[i] > 0 and correct[i] == 1 :
        penalty += false[i]

print(sum(correct),penalty)

Solution (Python):
n,m = map(int, input().split(" "))
a=[list(map(str, input().split(" "))) for i in range(m)]
check = [False for i in range(n + 1)]
times = [False for i in range(n + 1)]

for i in range(m):
  
  
  if check[(int)(a[i][0])] == False and a[i][1] == "AC":
    
    check[(int)(a[i][0])] = True
  elif check[(int)(a[i][0])] == False and a[i][1] == "WA":
    times[(int)(a[i][0])] += 1
    

for i in range(n + 1):
  if check[i] == False:
    times[i] = 0
print(check.count(True), sum(times))

Solution (Python):
n,m=map(int,input().split())
p,s=[],[]
for i in range(m):
    a,b=map(str,input().split())
    p.append(int(a))
    s.append(b)
c,e=0,0
l=[0]*n
for i in range(m):
    if s[i]=="WA" and l[p[i]-1]==0:
        e+=1
    elif s[i]=="AC" and l[p[i]-1]==0:
        c+=1
        l[p[i]-1]=1
for i in range(m):
    if s[i]=="WA" and l[p[i]-1]==0:
        e-=1
print(str(c)+" "+str(e))

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

a = [False]*(N+1)
b = [0]*(N+1)



for i in range(M):
    c = input().split()
    if c[1] == "AC":
        a[int(c[0])] = True
    elif c[1] == "WA" and a[int(c[0])] == False:
        b[int(c[0])] += 1
            

for j in range(N+1):
    if a[j] == False:
        b[j] = 0
        
print(sum(a),sum(b))

Solution (Python):
n , m = (int(a) for a in input().split())
ans = [0]*n
ng = [0]*n
NG = 0
for i in range(m) :
    p,s = input().split()
    p = int(p)
    if s == "AC" :
        if ans[p-1] == 0 :
            NG += ng[p-1]
            ans[p-1] = 1
    else :
        if ans[p-1] == 0 :
            ng[p-1] += 1
 
print(ans.count(1) , NG)

Solution (Python):
N, M = map(int, input().split())
AC = [False] * (N + 1)
WA = [0] * (N + 1)
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S =='AC':
        AC[p] = True
    elif S == 'WA' and AC[p] == False:
        WA[p] += 1
print(sum(AC), sum([WA[i] for i, boo in enumerate(AC) if boo]))

Solution (Python):
N, M = map(int, input().split())
ans_num_lis = [0 for i in range(N)]
pre_ans_lis = [0 for i in range(N)]
ans_lis = [0 for i in range(N)]
for i in range(M):
  problem, result = input().split()
  problem_num = int(problem)
  if result == "WA":
    pre_ans_lis[problem_num-1] += 1
  if result == "AC" and not ans_num_lis[problem_num-1]:
    ans_num_lis[problem_num-1] = 1
    ans_lis[problem_num-1] = pre_ans_lis[problem_num-1]

print(sum(ans_num_lis), sum(ans_lis))

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

ac = set()
wa = {}

for i in range(m):
    p, s = input().split()
    if s == 'AC':
        ac.add(p)
        wa[p] = wa.get(p, 0)
    else:
        if not p in ac:
            wa[p] = wa.get(p, 0)+1

ans = sum([wa[i] for i in ac])

print(len(ac), ans)

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

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

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

Solution (Python):
N,M=map(int,input().split())
correct=[]
penalty=[0 for i in range(N+1)]
for i in range(M):
  p,S=input().split()
  p=int(p)
  if S=="AC":correct.append(p)
  else:
    if p not in correct: penalty[p] += 1

correct = set(correct)

ans = 0
for p in correct:
  ans += penalty[p]
      
print(' '.join([str(len(correct)), str(ans)]))

Solution (Python):
N, M = map(int, input().split())
ps = [list(map(str, input().split())) for _ in range(M)]
ans = [0,0]
cnt = [0]*(N+1)
memo = [0]*(N+1)
for i in range(M):
    p = int(ps[i][0])
    s = ps[i][1]
    if memo[p] == 1:
        continue
    else:
        if s == "WA":
            ans[1] += 1
            cnt[p] += 1
        else:
            ans[0] += 1
            cnt[p] += 1
            memo[p] = 1

for i in range(1,N+1):
    if memo[i] == 0:
        ans[1] -= cnt[i]
        
print(*ans)

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

penalty_list = [0]*n 
result_list = [0]*n 

for i in range(m):
  if sub_list[i][1] =='AC':
    result_list[int(sub_list[i][0]) -1] = 1
  else:
    if result_list[int(sub_list[i][0]) -1] == 0:
      penalty_list[int(sub_list[i][0]) -1] += 1

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

print(f'{ac_count} {wa_count}')

Solution (Python):
n,m=map(int,input().split())
AClst=[0]*n
WAlst=[0]*n
AC=0
WA=0
for i in range(m):
  res = input().rstrip().split(' ')
  no=int(res[0])
  ans=str(res[1])
  if AClst[no-1]==0 and ans=="WA":
    WAlst[no-1]+=1
  elif AClst[no-1]==0 and ans=="AC":
    AClst[no-1]=1
for j in range(n):
  if AClst[j]==0 and WAlst[j]>0:
    WAlst[j]=0
  AC+=AClst[j]
  WA+=WAlst[j]
print(AC, WA)

Solution (Python):
N, M = map(int, input().split())
WA = [0] * (N+1)
AC = [0] * (N+1)
Q = [list(input().split()) for _ in range(M)]
for p, s in Q:
  p = int(p)
  if AC[p] == 1:
    continue
  if s == "WA":
    WA[p] += 1
  else:
    AC[p] = 1
ans = 0
for w, a in zip(WA, AC):
  if a:
    ans += w
print(sum(AC), ans)

Solution (Python):
n ,m = map(int,input().split())
ok = [False] * n
wa = [0] * n
for i in range(m):
    p,s = input().split()
    if s == 'AC':
        ok[int(p)-1] = True
    elif not(ok[int(p)-1]):
        wa[int(p)-1] += 1
wa_sum = sum([wa[i] * ok[i] for i in range(n)])
print(sum(ok),wa_sum)

Solution (Python):
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
ans,pena=0,0
N,M=MI()
P=[0]*N
PENA=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  p-=1
  if s=='AC':
    if P[p]==0:
      ans+=1
      P[p]=1
      if PENA[p]!=0:
        pena+=PENA[p]
  if s=='WA':
    if P[p]==0:
      PENA[p]+=1
print(ans,pena)

Solution (Python):
N, M = map(int, input().split())
A = [False] * N
B = [0] * N
cnt = 0
for i in range(M):
    p, S = input().split()
    if not A[int(p) - 1]:
        if S == 'AC':
            cnt += 1
            A[int(p) - 1] = True
        else:
            B[int(p) - 1] += 1
_cnt = 0
for i in range(N):
    if A[i]:
        _cnt += B[i]
print(cnt, _cnt)

Solution (Python):
N,M= map(int, input().split())
p = [0] * M
S = [0] * M
for i in range(M):
    p[i], S[i] = map(str, input().split())
    
AC_list=[0]*N
pena=[0]*N
for i in range(M):
    if S[i]=='AC':
        AC_list[int(p[i])-1]+=1
    else:
        if AC_list[int(p[i])-1]==0:
            pena[int(p[i])-1]+=1
num=0
num1=0
for i in range(N):
    if AC_list[i]!=0:
        num+=1
        num1+=pena[i]
print(num ,num1)

Solution (Python):

def resolve():
    
    N, M = map(int, input().split())

    ans = [False]*N
    WA = [0]*N
    ac, wa_tot = 0, 0
    for _ in range(M):
        q, s = input().split()
        q = int(q)-1
        if ans[q]:
            continue
        if s == "AC":
            ans[q] = True
            ac += 1
            wa_tot += WA[q]
        if s == "WA":
            WA[q] += 1

    print(ac, wa_tot)

if __name__ == "__main__":
    resolve()

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

wa_n = [0] * n
ac_n = [0] * n

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


print(sum(ac_n), sum(list(itertools.compress(wa_n, ac_n))))

Solution (Python):


"""
https://atcoder.jp/contests/abc151/tasks/abc151_c
Welcome at atcoder
"""


if __name__ == "__main__":
    n, m = list(map(int, input().split()))

    accepted = [False for _ in range(n+5)]
    wrong = [0 for _ in range(n+5)]
    ac = wa = 0

    for _ in range(m):
        p, s = input().split()
        p = int(p)

        if accepted[p]: continue
        elif s == "WA": wrong[p] += 1
        elif s == "AC":
            ac += 1
            wa += wrong[p]
            accepted[p] = True

    print(f"{ac} {wa}")

Solution (Python):
n, m = map(int, input().split())
if m > 0:
    p, s = zip(* [input().split() for _ in range(m)])
else:
    p = []
    s = []

ac_dict = {str(i): False for i in range(1, n + 1)}
wa_dict = {str(i): 0 for i in range(1, n + 1)}
ac_num = 0
wa_num = 0
for p_i, s_i in zip(p, s):
    if ac_dict[p_i] == False:
        if s_i == 'AC':
            ac_num += 1
            wa_num += wa_dict[p_i]
            ac_dict[p_i] = True
        elif s_i == 'WA':
            wa_dict[p_i] += 1
print('{} {}'.format(ac_num, wa_num))

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

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

N, M = map(int, input().split())
L = [[False, 0] for i in range(N)]
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == "WA":
        if not L[p - 1][0]:
            L[p-1][1] += 1
    elif S == "AC":
        if not L[p - 1][0]:
            L[p-1][0] = True

AC = 0
PN = 0
for i in range(N):
    if L[i][0]:
        AC += 1
        PN += L[i][1]
print(AC, PN)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    n, m = [int(x) for x in input().split()]
    ac = set()
    pen = defaultdict(int)
    pp = 0
    for _ in range(m):
        p, S = [x for x in input().split()]
        if p not in ac and S == 'AC':
            ac.add(p)
            pp += pen[p]
        else:
            if not p in ac:
                pen[p] += 1

    print(len(ac), pp)

t = 1

for case in range(1,t+1):
    ans = solve()


"""


"""

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

Done = [False] * N
W = [0] * N
AC = 0
WA = 0
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if Done[p]:
        continue
    else:
        if S == 'WA':
            W[p] += 1
        else:
            AC += 1
            WA += W[p]
            Done[p] = True
print(AC, WA)

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

(n, m), d, a, b = map(int, input().split()), defaultdict(int), 0, 0
for i in range(m):
	p, s = input()[:-1].split(); p = int(p)
	if d[p] == sys.maxsize: continue
	if s == 'WA': d[p] += 1
	if s == 'AC': b += abs(d[p]); a += 1; d[p] = sys.maxsize
print(a, b)

Solution (Python):
import numpy as np
N, M = map(int, input().split())
l = np.zeros((N, 2), dtype = int)
for i in range(M):
    p, S = map(str, input().split())
    if S == 'AC':
        l[int(p) - 1, 0] = 1
    elif S =='WA' and l[int(p) - 1, 0] == 1:
        continue
    else:
        l[int(p) - 1, 1] += 1
print(np.sum(l[:, 0]), np.sum(l[l[:, 0] == 1, 1]))

Solution (Python):
n, m = map(int, input().split())
ps = [input().split() for i in range(m)]
b = [False] * n
wa = [0] * n
for i in ps:
  if b[int(i[0])-1] == False and i[1] == "AC":
    b[int(i[0])-1] = True
  elif b[int(i[0])-1] == False and i[1] == "WA":
    wa[int(i[0])-1] += 1
print(b.count(True),end=" ")
ans = 0
for i in range(n):
    if b[i]:
        ans += wa[i]
print(ans)

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

for _ in range(m) :
    pS[_][0] = int(pS[_][0])

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

for i in range(m) :
    if pS[i][1] == "AC" :
        if ac[pS[i][0]-1] == 0 :
            ac[pS[i][0]-1] += 1
    elif pS[i][1] == "WA" :
        if ac[pS[i][0]-1] == 0 :
            wa[pS[i][0] - 1] += 1

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

print(sum(ac),awa)

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

judge = [False]*N
WAcnt = [0] * N
ACcnt = 0
for i in range(M):
    p,S = (x for x in input().split())
    p = int(p)
    if judge[p-1] == False:
        if S == "AC":
            judge[p-1] = True
            ACcnt += 1
        else:
            WAcnt[p-1] += 1

WAans = 0
for i in range(N):
    if judge[i] == True:
        WAans += WAcnt[i]

print(ACcnt,WAans)

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

correct = [0] * N
penalty = [0] * N
for p, s in ps:
    p = int(p)
    if correct[p-1] == 1:
        continue
    if s == 'AC':
        correct[p-1] = 1
    else:
        penalty[p-1] += 1
print(sum(correct), sum([p*c for p, c in zip(penalty, correct)]))

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

q=['WA' for i in range(n)]
w=[0 for i in range(n)]
ans=0
pen=0
for i in range(m):
    p,s=input().split()
    pi=int(p)-1
    if s=='AC' and q[pi]=='WA':
        ans+=1
        pen+=(w[pi])
        q[pi]='AC'
    else:
        w[pi]+=1
        

        
print(ans,pen)

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

cnt = [[0, 0] for _ in range(N + 1)]
for p, s in X:
    if s == "AC":
        cnt[p][0] = 1
    elif cnt[p][0] == 0:
        cnt[p][1] += 1

ac = sum(v for v, _ in cnt)
wa = 0
for i in range(N + 1):
    if cnt[i][0] == 1:
        wa += cnt[i][1]
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] = map(str,input().split())
    
AC = [0]*N
WA = [0]*N
ACcount = 0
WAcount = 0
for i in range(M):
    if AC[int(P[i])-1]==0:
        if S[i] == 'WA':
            WA[int(P[i])-1] += 1
        if S[i] == 'AC':
            ACcount += 1
            AC[int(P[i])-1] = 1 
for i in range(N):
    if AC[i] == 1:
        WAcount += WA[i]
print(ACcount,WAcount)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
dic = defaultdict(int)
ac,wa = 0,0
for i in range(m):
    p,S = input().split()
    if dic[p] != -1:
        if S == 'AC':
            wa += dic[p]
            ac += 1
            dic[p] = -1
        else:
            dic[p] += 1
print(ac,wa)

Solution (Python):
def solve():
  ans = [0,0]
  N, M = map(int, input().split())
  WAs = [0]*N
  for i in range(M):
    p, S = input().split()
    p = int(p)
    if WAs[p-1]>=0:
      if S=='WA':
        WAs[p-1] += 1
      if S=='AC':
        ans[0] += 1
        ans[1] += WAs[p-1]
        WAs[p-1] = -1
  return ans
print(*solve())

Solution (Python):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,M = map(int,readline().split())
WA_cnt = [0]*(N+1)
WA_use = [0]*(N+1)
A = []
cnt = 0
for _ in range(M):
    p,S = readline().decode().split()
    p = int(p)
    if S == 'AC' and WA_use[p] == 0:
        A.append(p) 
        cnt += WA_cnt[p]
        WA_use[p] = 1
    else:
        WA_cnt[p] += 1
        
print(len(set(A)),cnt)

Solution (Python):
n, m = map(int, input().split())
pena = [0 for i in range(n)]
cor = set([])
for i in range(m):
    pi, si = input().split()
    pi = int(pi) - 1
    if si == 'AC':
        cor.add(pi)
    else:
        if pi not in cor:
            pena[pi] += 1

ans = 0
for i in cor:
    ans += pena[i]
print(len(cor), ans)

Solution (Python):
N,M = map(int,input().split())
A = [list(input().split()) for _ in range(M)]
C = {str(i):0 for i in range(1,N+1)}
for i in range(M):
    p,s = A[i]
    if s=="AC":
        C[p] = 1
D = {str(i):0 for i in range(1,N+1)}
cnt = 0
for i in range(M):
    p,s = A[i]
    if C[p]==1 and D[p]==0 and s=="WA":
        cnt += 1
    elif s=="AC":
        D[p] = 1
ac = 0
for i in range(1,N+1):
    ac += C[str(i)]
print(ac,cnt)

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

ac = [0] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if s == "AC":
        ac[p] = 1
        continue
    if ac[p] == 0:
        pena[p] += 1
ans = [0,0]
for x,y in zip(ac[1:],pena[1:]):
    if x == 1:
        ans[0] += 1
        ans[1] += y
print(" ".join(map(str, ans)))

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

ac = [False] * N
wa = [0] * N
for _ 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())
ps = [input().split() for _ in range(m)]

p_ac = dict()
ac = 0
wa = 0
for i in range(m):
    p, s = ps[i]
    if p not in p_ac and s == 'AC':
        p_ac[p] = i
        ac += 1

for i in range(m):
    p, s = ps[i]
    if p in p_ac.keys() and s == 'WA':
        if i < p_ac[p]:
            wa += 1
print(ac, wa)

Solution (Python):
N, M = [int(x) for x in input().split()]

ok = 0
ng = 0
ng_l = {}
end = set()

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

    if not p in end:
        if S == 'AC':
            ok += 1
            end.add(p)

            if p in ng_l:
                ng += ng_l[p]
        else:
            if p in ng_l:
                ng_l[p] += 1
            else:
                ng_l[p] = 1

print('{} {}'.format(ok, ng))

Solution (Python):
N, M = map(int, input().split())
wro = dict()
cor = set()

for _ in range(M):
    p, s = input().split()
    if s == 'AC':
        cor.add(p)
    elif s == 'WA' and p not in cor:
        wro[p] = wro.get(p, 0) + 1

wro_num = 0
for i in cor:
    wro_num += wro.get(i, 0)

print(len(cor), wro_num)

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

Solution (Python):
N, M = map(int, input().split())
p = dict()
ac = dict()
ans, penalty = 0, 0
for _ in range(M):
  tmp = input().split()
  if tmp[0] in ac:
    continue
  if tmp[1] == 'AC':
    ans += 1
    ac[tmp[0]] = 1
    penalty += p.get(tmp[0], 0)
  else:
    p[tmp[0]] = p.get(tmp[0], 0) + 1
print(ans, penalty)

Solution (Python):

(n, m,), *sub = [i.split() for i in open(0)]

r = {str(i+1): 0 for i in range(int(n))}
pen = 0
ac = 0
for p, s in sub:
    if r[p]>-1:
        if s == "WA":
            r[p]+=1
        else:
            ac += 1
            pen += r[p]
            r[p] = -1
print(ac, pen)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

print(sum(ac), wa)

Solution (Python):
N, M = map(int,input().split())
lst = [[] for i in range(N+1)]
for i in range(M):
    p,s = map(str,input().split())
    lst[int(p)].append(s)


ac = 0
wa = 0
for i in range(1,N+1):
    flg = 0
    tmp_wa = 0
    for submit in lst[i]:
        if submit == 'WA':
            tmp_wa += 1
        else:
            ac += 1
            wa += tmp_wa
            break
print(ac,wa)

Solution (Python):
import sys
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    sub = [0]*n
    c = 0
    t = 0
    for _ in range(m):
        p,s = SL()
        p = int(p)
        if sub[p-1]==-1: continue

        if s=='AC':
            t += sub[p-1]
            sub[p-1] = -1
            c += 1
        elif s=='WA':
            sub[p-1] += 1
    print(c,t)
    return

if __name__=='__main__':
    Main()

Solution (Python):
N,M = map(int,input().split())
A = [list(input().split()) for _ in range(M)]
C = {str(i):0 for i in range(1,N+1)}
for i in range(M):
    p,s = A[i]
    if s=="AC":
        C[p] = 1
D = {str(i):0 for i in range(1,N+1)}
cnt = 0
for i in range(M):
    p,s = A[i]
    if s=="WA":
        if C[p]==1 and D[p]==0:
            cnt += 1
    else:
        D[p] = 1
ac = 0
for i in range(1,N+1):
    if C[str(i)]==1:
        ac += 1
print(ac,cnt)

Solution (Python):
import math
import collections
import fractions
import itertools

def solve():
    n, m = map(int, input().split())
    mon = [0]*n
    mon2 = [0]*n
    for i in range(m):
        q, a = input().split()
        q = int(q)
        if a == "AC":
            mon[q-1] = 1
        else:
            if mon[q-1] == 0:
                mon2[q-1] += 1
    ac, pena = 0, 0
    for i in range(n):
        if mon[i] == 1:
            ac += 1
            pena += mon2[i]
    print(ac, pena)
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
n, m = map(int, input().split())
cnt = 0
pena = 0
L = [-1]*(n+1)
C = [0]*(n+1)
for _ in range(m):
  p, s = input().split()
  p = int(p)
  if s == "WA":
    if L[p] == -1:
      C[p] += 1
  else:
    if L[p] == -1:
      L[p] = 1
      cnt += 1
      pena += C[p]
print(cnt, pena)