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())
lp, ls = [0] * m, [0] * m
for i in range(m):
    lp[i], ls[i] = input().split()

lpu = list(set(lp))
lac = [0] * n
lwa = [0] * n

for j in range(m):
    p = int(lp[j]) - 1
    if lac[p] == 0:
        if ls[j] == 'AC':
            lac[p] = 1
        else:
            lwa[p] += 1

print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))

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

n, m = map(int, readline().split())
ac_lst = [False] * (n + 1)
wa_lst = [0] * (n + 1)
w = 0
for _ in range(m):
    a, b = readline().split()
    a = int(a)
    if ac_lst[a]:
        continue
    if b == b'WA':
        wa_lst[a] += 1
    else:
        w += wa_lst[a]
        ac_lst[a] = True
print(sum(ac_lst), w)

Solution (Python):
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict
n,m=map(int, input().split())
ac=set()
ac_cnt=0
wa_cnt=0
d_ac=defaultdict(int)
d_wa=defaultdict(int)
for i in range(m):
    p,s=nm()
    if s=='AC':
        if int(p) in ac:
            continue
        ac.add(int(p))
        ac_cnt+=1
    elif s=='WA':
        if int(p) in ac:
            continue
        d_wa[p]+=1
 
for a in ac:
    wa_cnt+=d_wa[str(a)]
 
print(ac_cnt,wa_cnt)

Solution (Python):
n, m = map(int, input().split())
ac_lst = [False] * (n + 1)
wa_lst = [0] * (n + 1)
w = 0
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if ac_lst[a]:
        continue
    if b == 'WA':
        wa_lst[a] += 1
    else:
        w += wa_lst[a]
        ac_lst[a] = True
print(sum(ac_lst), w)

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

lpu = list(set(lp))
lac = [0] * n
lwa = [0] * n

for j in range(m):
    p = int(lp[j]) - 1
    if lac[p] == 0:
        if ls[j] == 'AC':
            lac[p] = 1
        else:
            lwa[p] += 1
    else:
        continue

print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))

Solution (Python):
n, m = map(int, input().split())
ac_lst = [False] * (n + 1)
wa_lst = [0] * (n + 1)
w = ac = 0
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if ac_lst[a]:
        continue
    if b == 'WA':
        wa_lst[a] += 1
    else:
        ac += 1
        w += wa_lst[a]
        ac_lst[a] = True
print(ac, w)

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

penalty = 0

corrected = {}
wa = {}

for i in range(m):
  pi, si = input().split()
  if (si == 'AC' and not corrected.get(pi)):
    corrected[pi] = True
  elif (si == 'WA' and not corrected.get(pi)):
    wa[pi] = wa[pi] + 1 if wa.get(pi) else 1

correct = len(corrected.keys())
for i in corrected.keys():
	penalty += wa[i] if  wa.get(i) else 0

print("{} {}".format(correct, penalty))

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

tmp_dict = {} 
result_dict = {} 

for _ in range(M):
  quiz, res = input().split()	
  
  if quiz not in tmp_dict:
    
      tmp_dict[quiz] = 0
      
  
  if res == "AC" and quiz not in result_dict: 
    wa_count = tmp_dict.pop(quiz)
    result_dict[quiz] = wa_count

  
  if res == "WA" and quiz not in result_dict: 
    tmp_dict[quiz] += 1


print(len(result_dict), sum(result_dict.values()))

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict
n,m=map(int, input().split())
ac=set()
ac_cnt=0
wa_cnt=0
d_ac=defaultdict(int)
d_wa=defaultdict(int)
for i in range(m):
    p,s=nm()
    if s=='AC':
        if int(p) in ac:
            continue
        ac.add(int(p))
        ac_cnt+=1
    elif s=='WA':
        if int(p) in ac:
            continue
        d_wa[p]+=1

for a in ac:
    wa_cnt+=d_wa[str(a)]

print(ac_cnt,wa_cnt)

Solution (Python):
n, m = map(int, input().split())
wa = [0]*(10**5)
ac = [0]*(10**5)
WA = 0
for i in range(m):
    p, s = input().split()
    P = int(p)
    if ac[P] != 1:
        if s == "WA":
            wa[P] += 1
        else:
            ac[P] += 1
            WA += wa[P]
print(sum(ac), WA)

Solution (Python):
n,m=map(int,input().split())
ac={}
wa=[0]*n
a=0
w=0
for i in range(n):
    ac[i+1]=0
    
for i in range(m):
    l=input().split()
    if ac[int(l[0])]!='AC':
        if l[1]=='AC':
            ac[int(l[0])]='AC'
            a+=1
            w+=wa[int(l[0])-1]
        else:
            wa[int(l[0])-1]+=1
    if a==n:
        break
print(a,w)

Solution (Python):
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for _ in range(m):
  a,b=input().split()
  l[int(a)-1].append(b)
  
wacnt=0
accnt=0

for rl in l:
  cnt = 0
  for r in rl:
    if r == 'WA':
      cnt+=1
    elif r == 'AC':
      wacnt+=cnt
      accnt+=1
      break
      
print(accnt, wacnt)

Solution (Python):
n,m=map(int,input().split())
ac,wa=0,0
aced=0
p,s=0,0
l=[0 for _ in range(m)]
for i in range(m):
  p,s=input().split()
  p=int(p)
  l[i]=[p,s,i+1]
l.sort(key=lambda x: (x[0],x[2]))

cw=0
p=0
for i in range(m):
  s=l[i][1]
  r=p
  p=l[i][0]
  if aced!=p:
    if s=='AC':
      ac+=1
      aced=p
      if r==p:
        wa+=cw
        cw=0
      else:
        cw=0
    else:
      if r==p:
        cw+=1
      else:
        cw=1

  

  
  

print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
AC = set([])
ans_wa = 0
WA = {}
for i in range(M):
    p, S = input().split()
    if p in AC:
        continue
    if S == "AC":
        AC.add(p)
        if p in WA:
            ans_wa += WA[p]
    elif p in WA:
        WA[p] += 1
    else:
        WA[p] = 1
print(len(AC), ans_wa)

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

is_ac = [0 for i in range(n)]
cnt_wa = [0 for i in range(n)]
for p, s in ans:
  p = int(p) - 1
  if is_ac[p]:
    continue
  if s == 'AC':
    is_ac[p] = 1
  else:
    cnt_wa[p] += 1

cor = sum(is_ac)
pena = 0
for p, c in enumerate(is_ac):
  if c:
    pena += cnt_wa[p]

print(cor, pena)

Solution (Python):
N, M = map(int, input().split())
ACed = [0] * (N + 1)
WAed = [0] * (N + 1)
WA_count = 0
AC_count = 0
WA_sum = 0

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

    if s == 'WA':
        WAed[p] += 1

    if s == 'AC' and ACed[p] == 0:
        ACed[p] = 1
        AC_count += 1
        WA_sum += WAed[p]

print(AC_count, WA_sum)

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

Num = []
St = []

toi=set() 
for i in range(m):
    p, s = input().split()
    
    


    p=int(p)-1 

    if p in toi:
        continue 

    elif s=='AC':
        toi.add(p) 
        
    else: 
        pena[p]+=1
print(len(toi), sum(pena[p] for p in toi))

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

ac = 0
wac = 0
count = [0 for x in range(n+1)]

for i in range(m):
  a , b = input().split()
  c = int(a)
  if count[c] >= 0:
    if b == "AC":
      ac += 1
      wac += count[c]
      count[c] = -1
    else:
      count[c] += 1

print(ac, wac)

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

ac = [False] * n
pena = [0] * n

acCnt = 0
waCnt = 0
for i in range(m):
  p, s = input().split()
  p = int(p) - 1
  if ac[p]:
    continue
  if s == 'AC':
    ac[p] = True
    acCnt += 1
    waCnt += pena[p]
  else:
    pena[p] += 1

print(acCnt, waCnt)

Solution (Python):
N, M = map(int, input().split())
S=[[0, ""] for j in range(M)]
ACcheck=[False for j in range(N)]
AC=0
WA=[0 for j in range(N)]
WA2 = 0
for i in range(M):
  ps = input().split()
  S[i][0]=int(ps[0])
  S[i][1]=ps[1]
for i in range(M):
  if S[i][1]=="AC":
    if ACcheck[S[i][0]-1]==False:
      AC+=1
      ACcheck[S[i][0]-1]=True
      WA2+=WA[S[i][0]-1]
  else:
    if ACcheck[S[i][0]-1]==False:
      WA[S[i][0]-1]+=1

print(AC, WA2)

Solution (Python):
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(
            think(2, [[1, 'WA'], [1, 'AC'], [2, 'WA'], [2, 'AC'], [2, 'WA']]),
            (2, 2)
        )

    def test_2(self):
        self.assertEqual(
            think(100000, [[7777, 'AC'], [7777, 'AC'], [7777, 'AC']]),
            (1, 0)
        )

    def test_3(self):
        self.assertEqual(
            think(6, []),
            (0, 0)
        )


def solve():
    n, list_of_p_and_s = read()
    result = think(n, list_of_p_and_s)
    write(result)


def read():
    n, m = read_int(2)
    list_of_p_and_s = []
    for _ in range(m):
        p_and_s = input().split(' ')[:2]
        list_of_p_and_s.append([int(p_and_s[0]), p_and_s[1]])
    return n, list_of_p_and_s


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, list_of_p_and_s):
    ac = [False for _ in range(n + 1)]
    penalty = [0 for _ in range(n + 1)]

    for p, s in list_of_p_and_s:
        if s == 'AC':
            ac[p] = True
        elif s == 'WA':
            if ac[p]:
                continue
            else:
                penalty[p] += 1
        else:
            raise RuntimeError()

    count_a = 0
    sum_penalty = 0
    for a, p in zip(ac, penalty):
        if a:
            count_a += 1
            sum_penalty += p
    return count_a, sum_penalty


def write(result):
    print('{0:d} {1:d}'.format(result[0], result[1]))


if __name__ == '__main__':
    
    solve()

Solution (Python):


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

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

for i in range(m):
    
    if len(finished) == n:
        break

    s = input().split()

    if finished[int(s[0])] == 0:
        if s[1] != "AC":
                q_wa[int(s[0])] += 1
        else:
                finished[int(s[0])] = 1
                ac = ac + 1
                wa = wa + q_wa[int(s[0])]

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

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

for i in range(m):
    q_no_tmp,anser = input().split()
    q_no = int(q_no_tmp)
    if anser == "AC":
        ac_list[q_no] = 1
    else:
        if ac_list[q_no] != 1:
            wa_list[q_no] = wa_list[q_no] + 1 

wa_num = 0
ac_num = 0
for i in range(n + 1):
    if ac_list[i] != 1:
        wa_list[i] = 0
    else:
        ac_num = ac_num + 1
    wa_num = wa_num + wa_list[i]

print(ac_num,wa_num)

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

for i in range(m):
    p, s = map(str, input().split())
    p= int(p)
    if s == 'AC':
        ac[p] = 1
    elif ac[p] == 0:
        wa[p] += 1

wa_sum = 0
for w, a in zip(wa, ac):
    wa_sum += w*a
print(sum(ac), wa_sum)

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

ac_set = set()
penalty = 0
wa_count = [0] * (n+1)

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

    if s == "AC":
        if not p in ac_set:
            penalty += wa_count[p]
            ac_set.add(p)
    elif s == "WA":
        wa_count[p] += 1


print(len(ac_set), penalty)

Solution (Python):
N,M = [int(i) for i in input().split()]
nes = ['0'] * M
for i in range(M) :
    li = input().split()
    nes[i] = li
sum_ac = 0
sum_wa = 0
l = [0] * (N+1)
for i in range(N+1) :
    l[i] = True
r = [0] * (N+1)
rr = [0] * (N+1)
for i in range(M) :
    if nes[i][1] == "AC" :
        if l[int(nes[i][0])] :
            sum_ac+=1
            r[int(nes[i][0])]+=1
            l[int(nes[i][0])] = False
    if nes[i][1] == "WA" :
        if l[int(nes[i][0])] :
            sum_wa +=1
            rr[int(nes[i][0])] += 1
for i in range(1,N+1) :
    if r[i] == 0 :
        sum_wa -= rr[i]
print(sum_ac,sum_wa)

Solution (Python):
w,*d=[0]*10**6
a={0}
for t in open(0):
  p,s=t.split()
  p=int(p)
  if'AC'==s*(not p in a):w+=d[p];a|={p}
  d[p]+=s>'V'
print(len(a)-1,w)

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

AC, WA = 0, 0
for _ in range(M):
  p_str, s = map(str, input().split())
  p = int(p_str)
  if ac_cnt_tmp[p-1] == 1:
    continue
  if s == "WA":
    wa_cnt_tmp[p-1] += 1
  elif s == "AC":
    ac_cnt_tmp[p-1] = 1
    AC += 1
    WA += wa_cnt_tmp[p-1]
    
print(AC, WA)

Solution (Python):
w,*d=[0]*10**6
a={0}
for t in open(0):
  p,s=t.split()
  p=int(p)
  if'AC'==s*(not p in a):w+=d[p];a|={p}
  d[p]+=s>'V'
print(len(a)-1,w)

Solution (Python):
n, m = map(int, input().split())
 
sac = set()
lwa = [0] * n
 
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if p in sac:
        continue
    elif s == 'AC':
        sac.add(p)
    else:
        lwa[p] += 1

print(len(sac), sum(lwa[p] for p in sac))

Solution (Python):
import numpy as np

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


numWA = [0]*N
flgAC = [0]*N



for ii in range(M):
  pi,Si = input().split()
  pi = int(pi) - 1 
  
  if flgAC[pi] == 0:
    if Si == "AC":
      
      flgAC[pi] = 1
    elif Si == "WA":
      numWA[pi] += 1

countWA = 0
for ii in range(N):
  if flgAC[ii] == 1:
    countWA += numWA[ii]
print(np.sum(flgAC),countWA)

Solution (Python):
N,M=map(int,input().split())
ST=['WA'] * N
WA=[0]*N
OK=0
NG=0
for i in range(M):
  c,s = map(str,input().split())
  c = int(c)
  if s == 'WA':
    if ST[c-1] != 'AC':
      WA[c-1] += 1
  else:
    if ST[c-1] != 'AC':
      ST[c-1] = 'AC'
      OK += 1

for i,s in enumerate(ST):
  if s != 'AC':
    WA[i] = 0

print("{} {}".format(OK, sum(WA)))

Solution (Python):
N, M = list(map(int, input().split()))
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(str, input().split()))
  a=int(a)
  if not list_Flag[a-1] == 1:
    if b=='WA':
      list_WA[a-1]=list_WA[a-1]+1
    elif b=='AC':
      list_Flag[a-1]=1
penalty = [0] * N
for p in range(N):
    penalty[p]=list_WA[p]*list_Flag[p]
PE=sum(penalty)
AC=sum(list_Flag)
print(AC,PE)

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

Ans = 0
Pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if (S == 'AC') and (Q_n[p] == 0):
        Q_n[p] = 1
        Ans += 1
        Pen += C[p]
    elif (S == 'WA'):
        C[p] += 1
        
print(Ans, Pen)

Solution (Python):
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = list(map(int, readline().split()))
pS = [readline().decode('utf-8').split() for _ in range(M)]
WA_cnt = [0] * (N + 1)
ACed_list = [False] * (N + 1)
pena = 0

for p_, s in pS:
    p_ = int(p_)

    if ACed_list[p_]:
        continue
    if s == "WA":
        WA_cnt[p_] += 1
    else:
        ACed_list[p_] = True
        pena += WA_cnt[p_]

print(sum(ACed_list), pena)

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

for _ in range(M):
  p_str, s = map(str, input().split())
  p = int(p_str)
  if ac[p-1] == 1:
    continue
  if s == 'AC':
    ac[p-1] = 1
  if s == 'WA':
    wa[p-1] += 1

result = [x * y for x, y in zip(ac, wa)]
AC = sum(ac)
WA = sum(result)

print(AC, WA)

Solution (Python):

n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
p = [int(x[0]) for x in ps]
s = [x[1] for x in ps]

ac = 0
wa = 0

wa_count = [0] * (n+1)
close = [False] * (n+1)

for i in range(m):
    if (close[p[i]]):
        continue

    if (s[i] == "AC"):
        wa += wa_count[p[i]]
        ac+= 1
        close[p[i]] = True
    else:
        wa_count[p[i]] += 1

print(ac,wa,sep=' ')

Solution (Python):
N, M = map(int, input().split())
arr = [input().split() for i in range(M)]
s = [[0,0] for i in range(N)]
p = 0
a = 0
for i, j in arr:
    if j == 'AC':
        s[int(i)-1][0] = 1
    elif j == 'WA':
        if s[int(i)-1][0] == 1: 
            pass
        else:
            s[int(i)-1][1] += 1
for i, j in s:
    if i == 1:
        p += j
        a += 1
print(a, p)

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


correct = [0] * (n+1)
wrong = [0] * (n+1)



for _ in range(m):
    problem,result_text = input().split()
    problem = int(problem)
    
    if result_text == "AC":
        correct[problem]=1
        
    
    if result_text == "WA":
        if correct[problem] == 0:
            wrong[problem] += 1
    

for problem in range(n+1):
    if correct[problem] == 0:
        wrong[problem] = 0



print ( sum(correct), sum(wrong) )

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

AC = [0] * (N + 1)
WA = [0] * (N + 1)

for P, S in PS:
  P = int(P)
  if S == "AC":
    if AC[P] == 0:
      AC[P] = 1
  else:
    if AC[P] == 0:
      WA[P] += 1
      
answer_AC, answer_WA = 0, 0
for i in range(N+1):
  if AC[i]:
    answer_AC += 1
  if WA[i] and AC[i]:
    answer_WA += WA[i]

print(answer_AC, answer_WA)

Solution (Python):
N,M = map(int,input().split())
L = []
for i in range(M):
    L.append(list(map(str,input().split())))
from operator import itemgetter
L.sort(key=itemgetter(0))
count_AC = 0
count_WA = 0
temp = 0
p = 0


for i in range(M):
    
    if L[i][0] != p:
        p = L[i][0]
        temp = 0
        flag = 'WA'
        if L[i][1] == 'WA':
            temp += 1
        else:
            count_AC += 1
            flag = 'AC'
    else:
        if L[i][1] == 'WA':
            temp += 1
        else:
            if flag == 'WA':
                count_AC += 1
                count_WA += temp
                flag = 'AC'
            else:
                pass
            
    

print('{} {}'.format(count_AC, count_WA))

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

isAC = [0] * (N+1)
isWA = [0] * (N+1)

ACnum = 0
WAnum = 0

for _ in range(M):
    p, s = input().split()
    p = int(p)
    
    if isAC[p] == 1: continue
    if s == 'AC':
        isAC[p] += 1
        ACnum += 1
        WAnum += isWA[p]
    elif s == 'WA':
        isWA[p] += 1

print("%d %d"%(ACnum, WAnum))

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

wa = 0 
ac = 0 
for i in range(1, N + 1): 
        if not p[i]:
                continue
        else:
                tp = 0 
                for s in p[i]:
                        if s == "WA":
                                tp += 1
                        elif s == "AC":
                                ac += 1
                                wa += tp
                                break    

print(str(ac) + " " + str(wa))

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

lac = [0] * n
lwa = [0] * n

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

print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))

Solution (Python):
import sys
P = 0
N,M = map(int,input().strip().split())
if M == 0:
    print("{0} {1}".format(0,0))
    sys.exit()
ans_list = [list(input().strip().split()) for _ in range(M)]
result = [False] * N
wa_count = [0] * N
for ans in ans_list:
    if result[int(ans[0])-1] != True:
        if ans[1] == "WA":
            wa_count[int(ans[0])-1] += 1
        elif ans[1] == "AC":
            result[int(ans[0])-1] = True
for i in range(len(result)):
    if result[i] == True:
        P += wa_count[i]
print("{0} {1}".format(result.count(True),P))

Solution (Python):

def solve(N, M, A):

    A = [[int(x[0]), x[1]] for x in A]

    Unsolve = [0]*(N+1)
    Solved = set()
    ac = 0
    wa = 0
    for i in range(M):
        if A[i][0] not in Solved:
            if A[i][1] == 'WA':
                Unsolve[A[i][0]] += 1
            elif A[i][1] == 'AC':
                Solved.add(A[i][0])
                wa += Unsolve[A[i][0]]
                ac += 1

    return ac, wa

def main():
    N, M = map(int, input().split())
    A = [list(x for x in input().split()) for _ in range(M)]
    ans = solve(N, M, A)
    print(*ans)

if __name__ == "__main__":
    main()

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

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

AC = {i+1: 0 for i in range(N)}
WA = {i+1: 0 for i in range(N)}

for i in range(M):
    p_i, S_i = input().strip().split(' ')
    p_i = int(p_i)
    if S_i == 'WA' and AC[p_i] == 0:
        WA[p_i] += 1
    elif S_i == 'AC':
        AC[p_i] = 1

sum_AC = 0
sum_WA = 0
for i in range(N):
    if AC[i+1] == 1:
        sum_AC += 1
        sum_WA += WA[i+1]

print(sum_AC, sum_WA)

Solution (Python):
n, m = map(int, input().split())
AC = [0] * (n+1) 
b = [0] * (n+1) 

WA = 0

for i in [0]*(m):

    s = input().split()

    if AC[int(s[0])] == 0:
        if s[1] == "AC":
            AC[int(s[0])] = 1
            WA += b[int(s[0])]
        else:
            b[int(s[0])] += 1

print(sum(AC), WA)

Solution (Python):
import sys
from collections import defaultdict

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

wa=defaultdict(lambda: 0)
ac=set()
cnt = 0
for line in sys.stdin:
  p, s = line.split()
  p = int(p)
  if p in ac:
    continue

  if s == "AC":
    cnt+=1
    ac.add(p)
  else:
    wa[p] += 1

print(cnt, sum(wa[i] for i in ac))

Solution (Python):
def solved(p):
    return cwa[p] == -1


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

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

ac = cwa.count(-1)
print(ac, wa)

Solution (Python):
N,M = map(int,input().split())
AC = 0
WA = 0
L = [0 for i in range(N)]
for i in range(M):
    pi,Si = input().split()
    pi = int(pi)-1
    if L[pi] == 0 and Si == 'AC':
        AC += 1
        L[pi] = -1
    elif L[pi] != -1 and Si == 'WA':
        L[pi] += 1
    elif L[pi] > 0 and Si == 'AC':
        AC += 1
        WA += L[pi]
        L[pi] = -1
    else:
        pass

print(AC,WA)

Solution (Python):
import sys
from collections import defaultdict

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

wa=defaultdict(lambda: 0)
already=set()
ac = 0
for line in sys.stdin:
  p, s = line.split()
  p = int(p)
  if p in already:
    continue

  if s == "AC":
    ac+=1
    already.add(p)
  else:
    wa[p] += 1

print(ac, sum(wa[i] for i in already))

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

lac = set()
lwa = [0] * n
ac = 0
wa = 0

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if p in lac:
        continue
    if s == 'AC':
        lac.add(p)
        ac += 1
        wa += lwa[p]
    if s == 'WA':
        lwa[p] += 1

print(ac, wa)

Solution (Python):
n,m=map(int, input().split())
ac,wa=0,0
if m==0:
    print(ac,wa)
else: 
    l=[0]*n 
    r=[0]*n 
    for i in range(m):
        pa,s=map(str, input().split())
        p=int(pa)
        if l[p-1]==0 and s=='AC': 
            l[p-1]=1
            ac+=1
        elif l[p-1]==0 and s=='WA': 
            r[p-1]+=1
        else:
            continue
    for i in range(n):
        if l[i]==1:
            wa+=r[i]
        else:
            continue
    print(ac,wa)

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

cw = 0
dw = {}
ca = 0
d = {}
for i in range(m):
    p, s = input().split()
    if d.get(p) == "AC":
        continue
    if p not in dw:
        dw[p] = 0
    if s == "WA":
        dw[p] += 1
    else:
        ca += 1
        cw += dw[p]
    d[p] = s

print(ca, cw)

Solution (Python):
n,m=map(int,input().split())
l=[input().split() for i in range(m)]
a=[0 for i in range(n)]
p=[0 for i in range(n)]
for i in range(m):
  if l[i][1]=='AC':
    a[int(l[i][0])-1]=1
  else:
    if a[int(l[i][0])-1]!=1:
      p[int(l[i][0])-1]+=1
cta=0;ctp=0
for i in range(n):
  if a[i]==1:
    cta+=1
    ctp+=p[i]
print(cta,ctp)

Solution (Python):
import sys
from collections import defaultdict

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

wa = defaultdict(lambda: 0)
already = set()
for line in sys.stdin:
    p, s = line.strip().split()
    p = int(p)
    
    if p in already:
        continue
    
    if s == 'AC':
        ac += 1
        already.add(p)
    
    else:
        wa[p] += 1

print(ac, sum(wa[i] for i in already))

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

print(int(cnt_ac),int(cnt_wa))

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

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

    if s == "AC" and AC_list[p-1] == 0:
        PN += WA_list[p-1]
        AC_list[p-1] = 1
    
    else:
        WA_list[p-1] += 1


print(AC_list.count(1), PN)

Solution (Python):
N,M = (int(x) for x in input().split())
cor = 0
mis = 0
numList = [0] * N
misList = [0] * N

for _ in range(M):
    num,ans = input().split()

    if ans == 'WA':
        misList[int(num)-1] += 1
    else:
        if numList[int(num)-1] == 0:
            mis += misList[int(num)-1]
            cor += 1
            numList[int(num)-1] = 1

print(cor,mis)

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

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

    for _ in range(M):
        p, s = input().split()
        p = int(p)
        if is_already_ac[p]:
            continue
        if s == 'AC':
            is_already_ac[p] = True
        elif s == 'WA':
            count_wa[p] += 1

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

print(c_welcome_to_atcoder())

Solution (Python):
from collections import OrderedDict
n, m = map(int,input().split())
 
aclist = [0]*n
walist = [0]*n
wa = 0
for i in range(m):
  pp, s = input().split()
  p = int(pp) - 1
  if s == 'AC':
    if not aclist[p]:
      aclist[p] = 1
      wa += walist[p]
  else:
    if not aclist[p]:
      walist[p] += 1
"""
  pp, s = input().split()
  p = int(pp) - 1
  if s == 'AC' and not aclist[p]:
    aclist[p] = 1
    ac += 1
    wa += walist[p]
  else:
    walist[p] += 1
"""
print(sum(aclist), wa)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b


def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

n, m = MAP()


L = []
for i in range(m):
  l = S_LIST()
  L.append(l)



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


for i in range(m):
  p = int(L[i][0])-1
  ans = L[i][1]
  if ans == "WA":
    
    if ac[p] == 0:
      wa[p] = wa[p] + 1
  
  if ans == "AC":
    ac[p] = 1

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


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

Solution (Python):
import sys
import numpy as np

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

n_l = [False] * int(n)
w_l = [0] * int(n)

for i_s in i:
    p, c = i_s.split()
    p = int(p) - 1
    if n_l[p] == 1:
        continue

    if c == "AC":
        n_l[p] = True
    else:
        w_l[p] += 1

n_l = np.array(n_l)
w_l = np.array(w_l)
w_l = w_l[n_l]

print("{} {}".format(n_l.sum(), w_l.sum()))

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):
a = list(map(int,input().split()))
N = a[0]
M = a[1]

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

bool_ac = []
ac_sum = 0
wa = []
wa_sum = 0
for i in range(N):
  bool_ac.append(0)
  wa.append(0)


for i in range(M):
  j = list[i][0] - 1
  if list[i][1] == "AC" and bool_ac[j] != 1:
    bool_ac[j] = 1
    ac_sum += 1
    wa_sum += wa[j]
  elif list[i][1] == "WA":
    if bool_ac[j] == 0:
      wa[j] += 1

print(ac_sum, end=" "), print(wa_sum)

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

WA = [0 for i in range(N+1)]
AC = [0 for i in range(N+1)]

for i in range(M):
    if PS[i][1] == "WA":
        if AC[PS[i][0]] == 0:
            WA[PS[i][0]] += 1
    else:
        AC[PS[i][0]] = 1

pen,cor = 0,0
for i in range(N+1):
    if AC[i] == 1:
        pen += WA[i]
    cor += AC[i]

print(str(cor)+" "+str(pen))

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

a = [0]*(n+10)
w = [0]*(n+10)

for i in range(0, m):
    p, s = input().split()
    p = int(p)
    if ((s == "AC")&(a[p] == 0)):
        a[p] += 1
    if ((s == "WA")&(a[p] == 0)):
        w[p] += 1
ac = 0
wa = 0
for i in range(0, n+10):
    ac += a[i]
    if a[i]==1:
        wa += w[i]
print(str(ac)+" "+str(wa))

Solution (Python):
N,M=map(int,input().split())
if (M == 0):
    print(0,0)
    exit()
wacount = [0] * N
account = [0] * N
for idx in range(M):
    p,s=input().split()
    if (s =="WA" and account[int(p) -1] == 0):
        wacount[int(p) -1] += 1
    if (s == 'AC' and account[int(p)-1] == 0):
        account[int(p) -1] += 1

for idx in range(N):
    if (account[idx] == 0):
        wacount[idx] = 0
print(sum(account),sum(wacount))