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())
a = [False] * (n+1)
b = [0] * (n+1)

ac = 0
wa = 0
for i in range(m):
  p,s = input().split()
  p = int(p)
  
  if (not a[p]) and s == "WA":
    b[p] += 1
  elif (not a[p]) and s == "AC":
    ac += 1
    wa += b[p]
    a[p] = True
    
    
print(ac,wa)

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

ps_dic={}
for i in range(M):
  pi,si=input().split()
  if pi not in ps_dic:
    ps_dic[pi]=[si]
  else:
    ps_dic[pi].append(si)
  

total_ac=0
total_wa=0
for p in ps_dic:
  num_wa=0
  for s in ps_dic[p]:
    if s == "WA":
      num_wa+=1
    elif s == "AC":
      total_ac+=1
      total_wa+=num_wa
      break

print(str(total_ac) + " " + str(total_wa))

Solution (Python):

def main():
    N,M = map(int,input().split())
    P,S = [],[]
    for _ in range(M):
        p,s = map(str,input().split())
        p = int(p)
        P.append(p)
        S.append(s)
    AC = [0 for i in range(N+1)]
    for i in range(M):
        if S[i]=="AC" and AC[P[i]]==0:
            AC[P[i]] += 1
        else:
            pass
    
    WA = [0 for i in range(N+1)]
    WA_flg = [ False for _ in range(N+1)]
    for i in range(M):
        if AC[P[i]]==0:
            pass
        else:
            if WA_flg[P[i]]==True:
                pass
            else:
                if S[i] == "AC":
                    WA_flg[P[i]]=True
                else:
                    WA[P[i]] += 1

    print(sum(AC),end=" ")
    print(sum(WA))

if __name__ == '__main__':
    main()

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

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

Solution (Python):
n,m=map(int,input().split())
sub=[tuple(input().split()) for j in range(m)]
ac=[False for i in range(n)]
wa=[0 for i in range(n)]
for p,s in sub:
    p=int(p)
    if s=='AC':
        ac[p-1]=True
    else:
        if ac[p-1]==False:
            wa[p-1]+=1


ans=0
pena=0
for AC,WA in zip(ac,wa):
    if AC:
        ans+=1
        pena+=WA
print(ans,pena)

Solution (Python):
n, m = map(int, input().split())
is_ac = [False] * 200050
count_wa = [0] * 100050
numok = 0
numwa = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if is_ac[p]: 
        continue
    else: 
        if s == "AC":
            numok += 1
            is_ac[p] = True
        else:
            count_wa[p] += 1
for i in range(100040):
    if is_ac[i]:
        numwa += count_wa[i]
print("{0} {1}".format(numok, numwa))

Solution (Python):


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

    was = [0 for _ in range(N)]
    acs = [False for _ in range(N)]

    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC':
            acs[p] = True
        elif not acs[p]:
            was[p] += 1

    ans, pen = 0, 0
    for s, c in zip(acs, was):
        if s:
            ans += 1
            pen += c

    print(ans, pen)


if __name__ == '__main__':
    main()

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

for _ in range(m):
    p,s=input().split()
    p = int(p) - 1
    if ac_list[p] == 'AC': continue
    ac_list[p] = s
    if s == 'AC':
        ac += 1
        wa += wa_list[p]
    else:
        wa_list[p] += 1
print(ac,wa)

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

count = [0 for x in range(0, n)]
ac_list = set()
ans_ac = 0
ans_pn = 0
for i in range(0, m):
    ps, s = input().split(" ")
    ps = int(ps)

    if s == "AC":
        if ps not in ac_list:
            ans_pn += count[ps - 1]
            ans_ac += 1
            ac_list.add(ps)

    else:  
        count[ps - 1] += 1

print("%d %d" % (ans_ac, ans_pn))

Solution (Python):
n,m = map(int,input().split())
pen_list = [0 for i in range(n)]
pen_num = 0
ans_num = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if pen_list[p-1] != -1:
            pen_list[p-1] += 1
    else:
        if pen_list[p - 1] != -1:
            pen_num = pen_num + pen_list[p-1]
            pen_list[p-1] = -1
            ans_num = ans_num + 1
print(ans_num, pen_num)

Solution (Python):
def main():
    n,m = map(int,input().split())
    tf = [False]*n
    pnl = [0]*n
    for i in range(m):
        p,s = input().split()
        p = int(p)-1
        if tf[p] is False:
            if s == "WA":
                pnl[p] += 1
            else:
                tf[p] = True
    ac = sum(tf)
    wa_sum = 0
    for i,j in zip(pnl,tf):
        if j:
            wa_sum += i
    print(str(ac)+" "+str(wa_sum))
    
if __name__ == '__main__':
    main()

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

accepted = [False] * N
temp_p = [0] * N
p = 0
for i in range(M):
    pi, Si = input().split()
    pi = int(pi) - 1
    if not accepted[pi]:
        if Si == 'AC':
            p += temp_p[pi]
            accepted[pi] = True
        else:
            temp_p[pi] += 1
print(accepted.count(True), p)

Solution (Python):
N, M = map(int, input().split())
wrongnumber = [0] * N
ACset = set()
for i in range(M):
    p, S = input().split()
    if S == "AC":
        ACset.add(int(p)-1)
    else:
        if (int(p) - 1) not in ACset:
            wrongnumber[int(p) - 1] += 1
WAnumber = 0
ACnumber = len(ACset)
for j in ACset:
    WAnumber += wrongnumber[j]

print(ACnumber, WAnumber)

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

n_ac = [0] * n
n_wa = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1

    if s == 'AC':
        n_ac[p] += 1
    elif n_ac[p] == 0:
        n_wa[p] += 1

ans1 = ans2 = 0
for i in range(n):
    if n_ac[i] > 0:
        ans1 += 1
        ans2 += n_wa[i]

print(ans1, ans2)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    N,M = LI()
    WA = [0] * N
    AC = [False] * N

    for _ in range(M):
        P,S = input().split()
        p = int(P)-1
        if S == 'AC':
            AC[p] = True
        if not(AC[p]):
            WA[p] += 1

    for i in range(N):
        if not(AC[i]):
            WA[i] = 0
    print(sum(AC),sum(WA))


if __name__ == "__main__":
    main()

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

ac_set = set()
wa_lst = [0] * (N + 1)  
wa_sum = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        if p not in ac_set:
            ac_set.add(p)
            wa_sum += wa_lst[p]
    else:
        wa_lst[p] += 1

print(len(ac_set), wa_sum)

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

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

Solution (Python):
import numpy as np
N, M = map(int, input().split())

succ = [0] * N
fail = [0] * N

for i in range(M):
    p, S = input().split()
    p = int(p) - 1

    if S == 'AC':
        succ[p] = 1
    else:
        if succ[p] == 0:
            fail[p] += 1


succ = np.array(succ)
fail = np.array(fail) * succ

print(succ.sum(), fail.sum())

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


N, M = list(map(int, sys.stdin.buffer.readline().split()))
PS = [sys.stdin.buffer.readline().decode().rstrip().split() for _ in range(M)]

ac = np.zeros(N + 1, dtype=int)
wa = np.zeros(N + 1, dtype=int)

for p, s in PS:
    p = int(p)
    if s == 'AC':
        ac[p] = 1
    if s == 'WA':
        if ac[p]:
            continue
        wa[p] += 1
print(ac.sum(), wa[ac > 0].sum())

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

ans=0
pen=0
answered=set()
tp=[0]*(10**5+10)

for _ in range(M):
    P,S=input().split()
    p=int(P)
    if not p in answered:
        if S=='WA':
            tp[p]+=1
        elif S=='AC':
            answered.add(p)
            ans+=1
            pen+=tp[p]

print(ans,pen)

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
ps = []
p = []
s = []
for i in range(m):
    p_, s_ = input().split()
    p.append(int(p_))
    s.append(str(s_))

ac = 0
pen = 0
d = defaultdict(int)
for p_, s_ in zip(p, s):
    if s_ == "WA":
        if d[p_] != -1:
            d[p_] += 1
        else:
            pass
    else:
        if d[p_] == -1:
            pass
        else:
            pen += d[p_]
            d[p_] = -1
            ac += 1
print(ac, pen)

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


ans_d = {}

cnt_d = {}

for i in range(N):
    cnt_d[i+1] = 0

for i in range(M):
    p, s = input().split()
    if int(p) in ans_d: continue
    if s == 'AC':
        ans_d[int(p)] = cnt_d[int(p)]
    elif s == 'WA':
        cnt_d[int(p)] += 1


ans = 0
for k, v in ans_d.items():
    ans += v


print('{} {}'.format(len(ans_d), ans))

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

goal = [0] * (N + 1)
wrong = [0] * (N + 1)
ans = [0, 0]

for i in range(M):
  p, s =  map(str, input().split())
  if goal[int(p)] == 0:
    if s == "AC":
      ans[0] += 1
      ans[1] += wrong[int(p)]
      goal[int(p)] = 1
    else:
      wrong[int(p)] += 1
      
print(ans[0], ans[1])

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

teishutu = [[] for i in range(N)]

for i in range(M):
    p, s = input().split()
    teishutu[int(p) - 1].append(True if s == "AC" else False)

seitou = 0
penaruthi = 0

for lst in teishutu:
    is_ac = False
    wa_cnt = 0
    for b in lst:
        if b:
            is_ac = True
            break
        wa_cnt += 1

    if is_ac:
        seitou += 1
        penaruthi += wa_cnt

print(seitou, penaruthi)

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

n,m=map(int,input().split())
a=[list(input().split()) for i in range(m)]
a=sorted(a, key=lambda x: x[0])
ac=0
wa=0
if m==0:
    print(0,0)
    exit()
now=a[0][0]
my_bool=True
wa_pre=0
for i in range(m):
    if now!=a[i][0]:
        now=a[i][0]
        my_bool=True
        wa_pre=0
    if not my_bool:
        continue
    if a[i][1]=="AC":
        ac+=1
        wa+=wa_pre
        my_bool=False
    else:
        wa_pre+=1
print(ac,wa)

Solution (Python):
nm=list(map(int,input().split()))
ps=[]
for i in range(nm[1]):
    ps.append(list(input().split()))
    ps[-1][0]=int(ps[-1][0])
ac=[0]*nm[0]
wa=[0]*nm[0]
for i in range(nm[1]):
    if ps[i][1]=="AC":
        if ac[ps[i][0]-1]==0:
            ac[ps[i][0]-1]=1
        else:
            pass
    else:
        if ac[ps[i][0]-1]==0:
            wa[ps[i][0]-1]+=1
        else:
            pass
ans=0
for i in range(nm[0]):
    if ac[i]==1:
        ans+=wa[i]
print(sum(ac),ans)

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok


def main():
    N,M=mis()
    ac = set()
    pe = defaultdict(int)
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        if S == 'AC':
            ac.add(p)
        elif p not in ac:
            pe[p] += 1
    print(len(ac), sum(pe[p] for p in ac))




main()

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

for p, s in ps:
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  else:
    if ac[p] == 0:
      wa[p] += 1
wasum = 0
for i, j in zip(ac, wa):
  if i > 0:
    wasum += j
print(sum(ac), wasum)

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

ok = 0
no  = 0

for i in range(n):
    if cnt[i][1] > 0:
        ok += 1
        no += cnt[i][0]
print(ok,no)

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

pna=0
for i in range(N):
  if ac[i]==1:
    pna+=pn[i]
print(sum(ac),pna)

Solution (Python):
N, M = [int(i) for i in input().split()]
dic = {}

for _ in range(M):
    p, s = input().split()
    if p not in dic:
        dic[p] = [False, 0]
    isAC, WC = dic[p]
    if isAC:
        continue
    if s == "AC":
        dic[p][0] = True
    elif s == "WA":
        dic[p][1] += 1

correct = 0
penalty = 0

for v in dic.values():
    if v[0]:
        correct += 1
        penalty += v[1]

print(correct, penalty)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

c = [0 for i in range(N)]
ca = [0 for i in range(N)]
cw = [0 for i in range(N)]


cc = 0
for i in range(M):
    p,s = input().split()
    if s == "WA":
        if ca[int(p)-1] == 0:
            cw[int(p)-1] += 1
    else:
        if ca[int(p)-1] == 0:
            ca[int(p)-1] = 1


for i in range(N):
    if ca[i] == 1:
        cc += cw[i]
print(sum(ca),cc)

Solution (Python):
N, M = map(int, input().split())
f = [False]*N
ac = 0
wa = [0]*N
for _ in range(M):
    p, s = list(input().split())
    p = int(p)
    if s == 'AC' and not f[p-1]:
        f[p-1] = True
        ac += 1
    elif not f[p-1]:
        wa[p-1] += 1
w = 0
for i in range(N):
    if f[i]:
        w += wa[i]
print(ac, w)

Solution (Python):
import sys


stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) 
rs = lambda: stdin.readline().rstrip()  

N, M = rl()
solve = [False] * (N+1)
count = [0] * (N+1)
penalty = 0
for i in range(M):
    p, s = input().split()
    p = int(p)
    if solve[p]:
        continue
    if s == 'WA':
        count[p] += 1
    else:
        solve[p] = True
        penalty += count[p]

print(sum(solve), penalty)

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

t=[0]*n
t1=[0]*n

for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='AC':
        t[p-1]=1
    elif t[p-1]==0:
        t1[p-1]+=1

ans=0
ans1=0

for i in range(n):
    if t[i]==1:
        ans+=t1[i]

ans1=sum(t)

print(str(ans1)+' '+str(ans))

Solution (Python):

import sys
input = sys.stdin.readline

n,m = list(map(int,input().split()))
ps = [list(input().split()) for i in range(m)]
ps = [[int(v1),v2] for v1,v2 in ps]
pac = [0 for _ in range(n+1)]
pwa = [0 for _ in range(n+1)]
for p,s in ps:
    if pac[p]==1:
        continue
    if s=="AC":
        pac[p]=1
    else:
        pwa[p]+=1
ret_ac = sum(pac)
ret_penalty = 0
for i,v in zip(pac,pwa):
    if i==1:
        ret_penalty+=v
print("{} {}".format(ret_ac,ret_penalty))

Solution (Python):
n, m = map(int, input().split())
penalty = [0 for x in range(n+1)]
solved = [-1 for x in range(n+1)]
ans = 0
ans_penalty = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if s == "WA":
        if solved[p] == -1:
            penalty[p] += 1
    else:
        if solved[p] == -1:
            ans += 1
            ans_penalty += penalty[p]
            solved[p] = 0
print(ans, ans_penalty)

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

ac = [False] * N
pe = [0] * N
cnt = 0

for _ in range(M):
    p, s = input().split()
    p = int(p) - 1

    if ac[p]:
        continue

    if s == 'AC':
        ac[p] = True
        cnt += pe[p]
    else:
        pe[p] += 1

print(sum(ac), cnt)

Solution (Python):




from __future__ import print_function, division, unicode_literals

__metaclass__ = type

try:
    input = raw_input
    range = xrange
except NameError:
    pass


import sys











from collections import Counter


def main():
    N, M = map(int, input().split())
    AC = set()
    WA = Counter()
    for i in range(M):
        p, S = input().split()
        p = int(p) - 1
        S = S == 'AC'
        if S:
            AC.add(p)
        elif p not in AC:
            WA[p] += 1
    print(len(AC), sum(v for k, v in WA.items() if k in AC))


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop



readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

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

acs = 0
wro = 0

PROB = [0] * N
WRON = [0] * N

for _ in range(M):
    p, s = input().split()
    p = int(p) - 1

    if PROB[p] == 1:
        continue

    if s == 'AC':
        PROB[p] = 1
        acs += 1
    elif s == 'WA':
        WRON[p] += 1

for i in range(N):
    if PROB[i] == 1:
        wro += WRON[i]

print(str(acs)+" "+str(wro))

Solution (Python):

def solve():
    N, M = map(int, input().split())
    WA = dict()
    AC = dict()
    for i in range(1, M+1):
        p, S = input().split()
        if S == 'WA' and p not in AC:
            WA[p] = WA.get(p,0)+1
        if S == 'AC':
            AC[p] = 1

    return str(len(AC)) + ' ' + str(sum(WA.get(p,0) for p in AC))

if __name__ == '__main__':
    print(solve())

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

total_ac = 0
total_wa = 0
results = {}
for _ in range(m):
  pi, si = input().split()
  if results.get(pi) == None:
    results[pi] = {
      "AC": False,
      "CumWA": 0
    }
  if not results[pi]["AC"] and si == "AC":
    results[pi]["AC"] = True
    total_ac += 1
    total_wa += results[pi]["CumWA"] 
  elif not results[pi]["AC"] and si == "WA":
    results[pi]["CumWA"] += 1

print(total_ac , total_wa )

Solution (Python):
def joint(i):
    cnt = 0
    for node in line_dict[i]:
        if cnt_list[node] == -1:
            cnt += joint(node)



if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n, m = map(int, input().split())

    wa = 0

    wa_cnt = [0]*n
    for _ in range(m):
        p, result = input().split()
        p = int(p)-1
        if wa_cnt[p] == -1:
            continue
        else:
            if result == 'AC':
                wa += wa_cnt[p]
                wa_cnt[p] = -1
            else:
                wa_cnt[p] += 1

    print(str(wa_cnt.count(-1)) + ' ' + str(wa))

Solution (Python):
nm=input().split(" ")
N=int(nm[0])
M=int(nm[1])
log=[0]*N
wacount=0
account=0
for i in range(M):
  ps=input().split(" ")
  p=int(ps[0])-1
  s=True if ps[1]=="AC" else False
  if log[p]!=-1:
    if s:
      account+=1
      wacount+=log[p]
      log[p]=-1
    else:
      log[p]+=1
print(str(account)+" "+str(wacount))

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

for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and AC[p] == 0:
        AC[p] = 1
    else:
        if AC[p] == 0:
            WC[p] += 1

print(sum(AC), sum([wc if AC[i] == 1 else 0 for i, wc in enumerate(WC)]))

Solution (Python):


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

l=[0]*N


ans=[0,0]
for _ in range(M):
    num,judge=input().split()
    num=int(num)
    num-=1
    if l[num]==-1:
        continue
    else:
        if judge=="AC":
            ans[0]+=1
            ans[1]+=l[num]
            l[num]=-1
        else:
            l[num]+=1
    

print(*ans)

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    answers = inputs
    n_solve = 0
    n_pena = 0
    solve_progress = set()
    num_answers = Counter({})

    for ans in answers:
        a = ans.split()
        number = int(a[0])
        result = a[1]

        if number in solve_progress:
            continue
        if result == "AC":
            solve_progress.add(number)
            n_solve += 1
        else:
            num_answers[number] += 1

    for s in solve_progress:
        n_pena += num_answers[s]
    return "{} {}".format(n_solve, n_pena)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(M))
    print(ret)

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

WAsum=0
for i in range(1, N+1):
  if ACnum[i]>0:
    WAsum+=WAnum[i]
out=[sum(ACnum), WAsum]
print(*out)

Solution (Python):
n,m=map(int,input().split())
l=[list(map(str,input().split())) for i in range(m)]
a=0
b=0
r=[0]*n
q=[0]*n
for i in range(m):
    l[i][0]=int(l[i][0])
for i in range(m):
    if q[l[i][0]-1]==0 and l[i][1]=='WA':
        r[l[i][0]-1]+=1
    elif q[l[i][0]-1]==0 and l[i][1]=='AC':
        a+=1
        b+=r[l[i][0]-1]
        q[l[i][0]-1]=1
print(a,b)

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

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

ac,pena = 0,0
for a,w in count.values():
    ac += a
    if a:
        pena += w
print(ac, pena)

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

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

Solution (Python):

MOD = 10 ** 9 + 7

import math

import itertools



import copy


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default



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



if __name__ == "__main__":
    main()

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

l=[0]*n
cnt_ac=0
cnt_wa=0
for p,s in li:
 p=int(p)
 p-=1
 if l[p]=='AC':
  continue
 elif l[p]!='AC' and s=='AC':
  cnt_ac+=1
  cnt_wa+=l[p]
  l[p]='AC'
 elif l[p]!='AC' and s=='WA':
  l[p]+=1
print(cnt_ac,cnt_wa)

Solution (Python):
N,M=map(int,input().split())
AC=[0]*N
WA=[0]*N
for i in range(M):
    p,s=map(str,input().split())
    p=int(p)
    if 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

print(sum(AC),sum(WA))

Solution (Python):
n, m = map(int, input().split())
flags = [False]*n
num_ac = 0
num_wa = 0
wa_list = [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    if flags[p-1]:
        continue
    else:
        if s=='WA':
            wa_list[p-1] += 1
        else:
            flags[p-1] = True
            num_ac += 1
            num_wa += wa_list[p-1]

print(num_ac, num_wa)

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

pr = [False]*N
wa = [0]*N

acc = 0
wac = 0

for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if pr[p] == True:
        continue
    if S == "AC":
        pr[p] = True
    else:
        wa[p] += 1

for i in range(N):
    if pr[i]:
        acc += 1
        wac += wa[i]

print(acc, wac)

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

Solution (Python):
N,M=map(int,input().split())
WA_chk = [0] * (N+1)
AC_chk = [0] * (N+1)
result = [] * (M+1)
WA_ans = 0
AC_ans = 0
for i in range(M): 
    A = [str(i) for i in input().split()]
    if A[1] == "WA":
        WA_chk[int(A[0])] += 1
    else:
        if AC_chk[int(A[0])] ==0:
            AC_ans += 1
            WA_ans += WA_chk[int(A[0])]
            AC_chk[int(A[0])] = 1
print(str(AC_ans) + " " + str(WA_ans))

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

wa = [0 for i in range(N)]

ac = [0 for i in range(N)]

waans = 0
acans = 0

for i in range(M):
    if sub[i][1] == 'AC' and ac[int(sub[i][0])-1] == 0:
        acans += 1
        waans += wa[int(sub[i][0])-1]
        ac[int(sub[i][0])-1] = 1
    elif sub[i][1] == 'WA' and ac[int(sub[i][0])-1] == 0:
        wa[int(sub[i][0])-1] += 1

print(acans,waans)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nas = lambda: stdin.readline().split()
ns = lambda: stdin.readline().rstrip()  

n, m = na()
aced = [0] * n
pens = [0] * n
for i in range(m):
    p, s = nas()
    p = int(p)
    if s == "AC":
        aced[p-1] = 1
    else:
        if not aced[p-1]:
            pens[p-1] += 1
print(sum(aced), sum(pens[_] for _ in range(n) if aced[_]))

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

A = []
for  i in range(M):
    x = [x for x in input().split()]
    x[0] = int(x[0])
    A.append(x)

p = [0]*N
a = [False]*N

for i in range(M):
    t = A[i][0]-1
    if a[t]==True:
        pass
    else:
        if A[i][1] =='AC':
            a[t] = True
        else:
            p[t] += 1

ans_p = 0
for i in range(N):
    if a[i]==True:
        ans_p += p[i]

print(sum(a), ans_p)

Solution (Python):
n, m = map(int, input().split())
d = [False for _ in range(n)]
x = [0 for _ in range(n)]
penalty = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if d[p]:
        continue
    if s == 'AC':
        d[p] = True
        penalty += x[p]
    else:
        x[p] += 1

print(sum(d), penalty)

Solution (Python):
import numpy as np

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

result = [0] * N
wa = [0] * N



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

    if s == 'AC':
        result[p-1] = 1
    elif s == 'WA' and result[p-1] == 0:
        wa[p-1] += 1

ac = np.sum(np.array(result))
wa = np.sum(np.array(result)*np.array(wa))

print(int(ac), int(wa))

Solution (Python):

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

wa = [0]*(n+1)
solve = [False for _ in range(n+1)]
for p,s in ps:
    p = int(p)
    if s=="AC":
        solve[p] = True
    else:
        if not solve[p]:
            wa[p] += 1

ra = 0
rw = 0
for i in range(1,n+1):
    if solve[i]:
        ra += 1
        rw += wa[i]
print(ra,rw)

Solution (Python):
N, M = map(int, input().split())
ac = [0] * N
wa = [0] * N

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

Solution (Python):
n, m = map(int, input().split())
data = []
dict_q = dict()
wa = 0
ac = 0
finished = set()
for i in range(m):
    p, s = input().split()
    if s == "WA":
        if p in dict_q:
            dict_q[p] += 1
        else:
            dict_q[p] = 1
    else:
        if p in finished:
            continue
        finished.add(p)
        if p in dict_q:
            wa += dict_q[p]
        ac += 1
print("{} {}".format(ac,wa))

Solution (Python):
n, m = map(int, raw_input().split())
l = []
ac = set()
wa = {}
for i in range(m):
	a, b = raw_input().split()
	a = int(a)
	
	if a not in ac:
		if b == 'WA':
			if a in wa:
				wa[a] += 1
			else:
				wa[a] = 1
		else:
			ac.add(a)
ans = 0
for i in list(ac):
	if i in wa:
		ans += wa[i]
print len(ac), ans