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

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

    
    
    correct = [0] * N

    
    penalty = [0] * N

    
    pena = 0

    
    for _ in range(M):

        
        pi, si = input().split()
        
        pi = int(pi)

        
        if si == 'WA' and correct[pi - 1] == 0:
            
            penalty[pi - 1] += 1

        
        elif si == 'AC' and correct[pi - 1] == 0:
            
            correct[pi - 1] = 1
            
            pena += penalty[pi - 1]

    
    print(sum(correct), pena)


if __name__ == "__main__":
    main()

Solution (Python):
N,M=map(int,input().split())
AC=[0] * (N + 1)
WA=[0] * (N + 1)
cnt_AC=0
cnt_WA=0

for _ in range(M):
  i,s=input().split()
  i=int(i)
  if AC[i]==0:
    if s=='WA':
      WA[i]+=1
    if s=='AC':
      AC[i]=1
      cnt_WA+=WA[i]
cnt_AC=sum(AC)
print(cnt_AC,cnt_WA)

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

print(sum(AC),sum_WA)

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

submission = []
for i in range(n):
    submission.append([])

for i in range(m):
    pi, si = input().split()
    submission[int(pi) - 1].append(si)
    
n_ac = 0
n_penalty = 0
for i in range(n):
    if "AC" in submission[i]:
        n_ac += 1
        ac_index = submission[i].index('AC')
        n_penalty += ac_index
print(n_ac, n_penalty)

Solution (Python):
from collections import defaultdict

memo = dict()

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

for i in range(m):
    p, s = input().split()
    if p not in memo:
        memo[p] = [0, False]

    if memo[p][1]:
        continue

    v = memo[p]
    if s == 'AC':
        memo[p] = [v[0], True]
    else:
        memo[p] = [v[0]+1, False]        

ac, wa = 0, 0
for _,v in memo.items():
    w, a = v
    if a:
        ac += 1
        wa += w

print(ac, wa)

Solution (Python):
lst = []
n, m  = map(int, input().split())
for _ in range(m):
    i, h = input().split()
    lst.append([int(i), str(h)])

jdg_wa = [0] * n 
jdg_ac = [0] * n

penalty = 0
for _ in lst:
    idx = _[0] - 1
    if  jdg_ac[idx] != 1:
        if _[1] == 'WA':
            jdg_wa[idx] += 1
        elif _[1] == 'AC':
            jdg_ac[idx] = 1
            penalty +=  jdg_wa[idx]
print(sum(jdg_ac), penalty)

Solution (Python):
import sys
import math
import bisect
 
def main():
    n, m = map(int, input().split())
    wa = [0] * n
    ac = [0] * n
    penalty = 0
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if s == 'WA':
            wa[p] += 1
        else:
            if ac[p] == 0:
                ac[p] = 1
                penalty += wa[p]
    print('%d %d' % (sum(ac), penalty))
 
if __name__ == "__main__":
    main()

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

try_flags = [True] * N  
wa_list = [0] * N
ac_list = [0] * N

for _ in range(M):
    i, result = input().split()
    i = int(i) - 1
    if result == 'WA' and try_flags[i]:
        wa_list[i] += 1
    if result == 'AC' and try_flags[i]:
        ac_list[i] = 1
        try_flags[i] = False

ac_cnt = 0
wa_cnt = 0
for ac, wa in zip(ac_list, wa_list):
    if ac == 1:
        ac_cnt += ac
        wa_cnt += wa
print('{} {}'.format(ac_cnt, wa_cnt))

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

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

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

for i in range(M):
    a.append(map(str, input().split()))

p_sum = 0
s_sum = 0

s_dict = {}
p_dict = {}
for k in range(M):
    ps = list(a[k])

    if (ps[0] in p_dict) == True:
        if p_dict[ps[0]] == True:
            continue
    if ps[1] == "WA":  
        if (ps[0] in s_dict) == True:
            s_dict[ps[0]] += 1
        else:
            s_dict[ps[0]] = 1
    else:
        p_dict[ps[0]] = True
        p_sum += 1
        if (ps[0] in s_dict) == True:
            s_sum += s_dict[ps[0]]
        pre_s_sum = 0

print(str(p_sum) + " " + str(s_sum))

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
n,m=map(int,input().split())
AC=[0]*n
WA=[0]*n
WAc=0
for i in range(m):
	a,b=input().split()
	c=int(a)
	if AC[c-1]==0:
		if b=="AC":
			AC[c-1]+=1
		else:
			WA[c-1]+=1

for j in range(n):
	if AC[j]==1:
		WAc+=WA[j]

print(sum(AC),WAc)

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

check = [0 for i in range(N + 1)]
pAC = 0
pWA = 0
for p in Pn:
    x = int(p[0])
    if check[x] != -1:
        if p[1] == 'WA':
            check[x] += 1
        elif p[1] == 'AC':
            pWA += check[x]
            pAC += 1
            check[x] = -1

print(pAC, pWA)

Solution (Python):

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

p_S_list = []

WA = 'WA'
AC = 'AC'

question_list = [False] * N
WA_count_list = [0] * N

count_AC = 0
count_WA = 0

for i in range(M):
    p, S = input().split()
    int_p = int(p)
    
    if S == WA and question_list[int_p - 1] == False:
        WA_count_list[int_p - 1] += 1

    if S == AC and question_list[int_p - 1] == False:
        count_AC += 1
        count_WA += WA_count_list[int_p - 1]
        question_list[int_p - 1] = True

print(str(count_AC) + ' ' + str(count_WA))








'''
first_AC_index_list = []
AC_set = set([])

for j in range(M):
    p, S = input().split()
    int_p = int(p)
    p_S_list.append([int_p, S])

    if S == AC and (int_p not in AC_set):
        first_AC_index_list.append([j, int_p])
        AC_set.add(int_p)

count_AC = len(first_AC_index_list)
count_WA = 0









for i_list in first_AC_index_list:
    count_WA += p_S_list[:i_list[0]].count([i_list[1], WA])

ans = str(count_AC) + ' ' + str(count_WA)

print(ans)

'''

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

for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if ac[p] != -1:
            wa += ac[p]
            ac[p] = -1


    else:
        if ac[p] != -1:
            ac[p] += 1

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

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

Solution (Python):
N, M = map(int, input().split())
problems = [False] * (N+1)
penalty = [0]*(N+1)

for i in range(M):
    p, S = input().split()
    if S == 'AC':
        problems[int(p)] = True
    if S == 'WA' and problems[int(p)] is False:
        penalty[int(p)] += 1

ans_AC, ans_pena = 0, 0
for i in range(1, N+1):
    if problems[i] is True:
        ans_AC += 1
        ans_pena += penalty[i]


print(ans_AC, ans_pena)

Solution (Python):
n,m=[int(i) for i in input().split()]
AC=[False]*n
WA=[0]*n
for i in range(m):
    p,s=[_ for _ in input().split()]
    p=int(p)-1
    if s=="WA" and not AC[p]:
        WA[p]+=1
    elif s=="AC":
        AC[p]=True
ans=[0,0]
for i in range(n):
    if AC[i]:
        ans[0]+=1
        ans[1]+=WA[i]
print(*ans,sep=" ")

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if ac[p] != -1:
            pena += ac[p]
            ac[p] = -1

    else:
        if ac[p] != -1:
            ac[p] += 1


print(ac.count(-1), pena)

Solution (Python):
N, M = map(int, input().split())
dic = {i: 0 for i in range(1, N+1)}
ac_count = 0
wa_count = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'WA' and dic[p] >= 0:
        dic[p] += 1
    elif dic[p] >= 0:
        ac_count += 1
        wa_count += dic[p]
        dic[p] = -1
print(ac_count, wa_count)

Solution (Python):
n, m = map(int, input().split())
pr = {i: 0 for i in range(1, n+1)}
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and pr[p] >= 0:
        pr[p] += 1
    elif pr[p] >= 0:
        ac += 1
        wa += pr[p]
        pr[p] = -1
print(ac, wa)

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

prob = {i: 0 for i in range(1, n+1)}
ac, wa = 0, 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and prob[p] >= 0:
        prob[p] += 1
    elif prob[p] >= 0:
        ac += 1
        wa += prob[p]
        prob[p] = -1

print(ac, wa)

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

Qa,Qw = {}, {}
for _ in range(M):
    p, S = input().split()
    p = int(p)-1

    if p not in Qa:
        Qa[p] = 0

    if p not in Qw:
        Qw[p] = 0

    if S == 'AC':
        Qa[p] = 1
    elif S == 'WA':
        if Qa[p] <= 0:
            Qw[p] += 1

AC = sum([ac for ac in Qa.values()])
WA = sum([Qw[k] for k,v in Qa.items() if v > 0])
print( AC, WA)

Solution (Python):
a,b = map(int,input().split())
L1 = [0]*a
L2 = [0]*a
acc,wac = 0,0
for i in range(b):
    c,d = input().split()
    if d == "AC" and L2[int(c)-1] == 0:
        acc +=1
        L2[int(c)-1] = 1
        wac += L1[int(c)-1]
        continue
    
    else:
         L1[int(c)-1] += 1
print(acc,wac)

Solution (Python):
n, m = map(int, input().split())
passed = 0
failed = 0
dicto = {}

for i in range(1, n+1):
    dicto[i] = [False, 0]

for i in range(m):
    key, status = input().split()
    key = int(key)
    if status == 'WA' and not dicto[key][0]:
        dicto[key][1] += 1
    else:
        dicto[key][0] = True

for i in dicto:
    if dicto[i][0]:
        failed += dicto[i][1]
        passed += 1

print(passed, failed)

Solution (Python):
N, M = map(int, input().split())
Q = {i: 0 for i in range(1, 1 + N)}

correction = 0
penalty = 0

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

    
    if Q[p] > 0:
        continue

    if s:
        correction += 1
        penalty -= Q[p]
        Q[p] = 1
    else:
        Q[p] -= 1

print(correction, penalty)

Solution (Python):
import numpy as np

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

seikai = np.zeros(n)
matigai1 = np.zeros(n)
matigai2 = np.zeros(n)
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if seikai[p]==1:
        continue
    else:
        if s=='AC':
            seikai[p] = 1
            matigai2[p] = matigai1[p]

        else:
            matigai1[p] += 1

print(int(seikai.sum()), int(matigai2.sum()))

Solution (Python):
N, M=map(int,input().split())
if M==0:
	print("0 0")
else:
	ac=0
	pe=0
	ch=[0]*N
	Ch=[0]*N
	for i in range(M):
		a, b=input().split()
		a=int(a)-1
		if ch[a]==1:
			continue
		elif b=="WA":
			Ch[a]+=1
		else:
			ch[a]=1
			ac+=1
			pe+=Ch[a]
	print(ac,pe)

Solution (Python):
N, M = (int(x) for x in input().split())
ac_dir = {n:False for n in range(1, N+1)}
wa_dir = {n:0 for n in range(1, N+1)}
ac_count = 0
wa_count = 0
for _ in range(M):
    data = input().split()
    p = int(data[0])
    S = data[1]
    if ac_dir[p]:
        continue
    else:
        if S == "AC":
            ac_dir[p] = True
            ac_count += 1
            wa_count += wa_dir[p]
        elif S == "WA":
            wa_dir[p] += 1
print(ac_count, wa_count)

Solution (Python):
n,m=map(int,input().split())
ac=[[0,False] for i in range(n)]
for i in range(m):
    p=list(input().split(" "))
    x=p[0]
    y=p[1]
    if ac[int(x)-1][1]==True:
        pass
    else:
        if y=="WA":
            ac[int(x)-1][0]+=1
        elif y=="AC":
            ac[int(x)-1][1]=True
counter=0
acc=0
for i in range(n):
    if ac[i][1]:
        acc+=1
        counter+=ac[i][0]
print(acc,counter)

Solution (Python):
N, M = list(map(int, input().split()))
correct = 0
incorrect = 0
Q = [0] * N
num_WA = [0] * N
for i in range(M):
    s, t = input().split()
    s = int(s)

    if t == 'AC':
        if Q[s-1] == 1:
            continue
        else:
            Q[s-1] = 1
            correct += 1
            incorrect += num_WA[s-1]
    else:
        num_WA[s-1] += 1
print(correct, incorrect)

Solution (Python):
N, M = list(map(int,input().split()))
a = [False for i in range(N)]
wa = [0 for i in range(N)]
for i in range(M):
  p, s = input().split()
  pi = int(p)-1
  if s=="AC":
      a[pi] = True
  elif not a[pi]:
      wa[pi] += 1
print(sum([1 for ai in a if ai]), sum([wa[i] for i in range(N) if a[i]]))

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

Ques = [0]*(N + 1)

correct = 0
incorrect = 0

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

print(correct, incorrect)

Solution (Python):
N, M = map(int, input().split())
ERR = COR = 0
AC = [0]*N
WA = [0]*N

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

    if (t == 'AC' and AC[s] == -1):
        continue

    elif (t =='AC'):
        COR += 1
        AC[s] = -1
        ERR += WA[s]
    
    elif (t == 'WA'):
        WA[s] += 1

print(COR, ERR)

Solution (Python):
n, m = [int(x) for x in input().split()]
lst = [0]*(n+1)
a = 0
b = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if s == 'AC' and lst[p] is not None:
    a += 1
    b += lst[p]
    lst[p] = None
  elif s == 'WA' and lst[p] is not None:
    lst[p] += 1
print(a,b)

Solution (Python):

n, m = map(int, input().split())
solved = {}
penalty = {}
for case in range(m):
    p, s = input().split()
    p = int(p)

    if s=='AC':
        solved[p] = True
    else: 
        if p in solved:
            continue 
        else:
            penalty[p] = penalty.get(p, 0) + 1

total_penalty = 0
for key in solved:
    total_penalty += penalty.get(key, 0)

print(len(solved), total_penalty)

Solution (Python):
n, m = list(map(int, input().split()))
ac = set()
wa = {}
for i in range(m):
  p, s = input().split()
  p = int(p)
  if p in ac:
    continue
  if s == 'WA':
    wa[p] = wa.get(p, 0) + 1
  else:
    ac.add(p)
pe = 0
for p in set(ac) & set(wa.keys()):
    pe += wa[p]
print("%d %d" % (len(ac), pe))

Solution (Python):
n, m = map(int, input().split())
from collections import defaultdict as dd
d_ac = dd(lambda:0)
d_wa = dd(lambda:0)
for i in range(m):
  p, sc = input().split()
  if sc == "AC":
    d_ac[p] = 1
  if sc == "WA":
    if d_ac[p] == 0:
      d_wa[p] += 1

total_ac = sum(d_ac.values())
total_wa = 0
for key in d_ac.keys():
  if d_ac[key] == 1:
    total_wa += d_wa[key]
print(total_ac, total_wa)

Solution (Python):
def getinput(_debug):
    N = 0
    M = 0
    p = []
    S = []
    
    if _debug == 0:
        N, M = map(int,input().split())
        lines = [input() for x in range(M)]

    elif _debug == 1:
        f = open("3_sample1.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    elif _debug == 2:
        f = open("3_sample2.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    elif _debug == 3:
        f = open("3_sample3.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    
    for l in lines:
        ls = l.split(" ")
        p.append(int(ls[0]))
        S.append(ls[1])

    return N,M,p,S

N,M,p,S = getinput(0)

AC = [0] * N  
WA = [0] * N  
wa = 0


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

print("%d %d"%(sum(AC),wa))

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

solved = [0]* 10**5
penalty = [0]* 10**5
penalty_sum = 0
for _ in range(m):
    q, result = input().split()
    q = int(q) - 1
    
    if result == 'AC':
        if solved[q] == 0:
            solved[q] = 1
            penalty_sum += penalty[q]
    else:
        if solved[q] == 0:
            penalty[q] += 1

print(str(sum(solved)) + " " + str(penalty_sum))

Solution (Python):
n,m=map(int,input().split())
dic={}
ans=0
pen=0
for i in range(m):
    p,s=input().split()
    if p not in dic.keys():
        dic[p]={}
    if s=='AC':
        dic[p][s]=1
    if 'AC' not in dic[p].keys():
        if 'WA' not in dic[p].keys():
            dic[p][s]=0
        dic[p][s]+=1

for key in dic.keys():
    if 'AC' in dic[key].keys():
        ans+=1
        if 'WA' in dic[key].keys():
            pen+=dic[key]['WA']

print(str(ans)+' '+str(pen))

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

Solution (Python):
import numpy as np
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
d = np.zeros(N+1, dtype = 'int32')
t = 0
f = 0

for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    S = tmp[1]
    dp = d[p]
    if S == 'AC':
        if dp != -1:
            f += dp
            d[p] = -1
            t += 1
    elif dp != -1:
        d[p] += 1
print(t, f)

Solution (Python):
import numpy as np
N, M = map(int, input().split())
d = np.zeros(N+1, dtype = 'int32')
t = 0
f = 0
for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    S = tmp[1]
    dp = d[p]
    if S == 'AC':
        if dp != -1:
            f += dp
            d[p] = -1
            t += 1
    elif dp != -1:
        d[p] += 1
print(t, f)

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

ans_AC=AC.count(True)
ans_WA=0
for i in range(N):
    if AC[i]:
        ans_WA+=WA[i]
print(ans_AC,ans_WA)

Solution (Python):
import numpy as np
N, M = map(int, input().split())
d = np.array([0]*(N+1), dtype = 'int32')
t = 0
f = 0
for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    S = tmp[1]
    if S == 'AC':
        if d[p] != -1:
            f += d[p]
            d[p] = -1
            t += 1
    elif d[p] != -1:
        d[p] += 1
print(t, f)

Solution (Python):
N,M=[int(i) for i in input().split()]
AC,WA=[False]*N,[0]*N
ans_WA=0
for i in range(M):
    p,s=input().split()
    p=int(p)-1
    if AC[p]==False:
        if s=="AC":
            AC[p]=True
            ans_WA+=WA[p]
        if s=="WA":
            WA[p]+=1
    else:
        continue

ans_AC=sum(AC)
print(ans_AC,ans_WA)

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

AC,WA=[False]*N,[0]*N
panel=0
for i in range(M):
    p,s=input().split()
    p=int(p)-1
    if AC[p]:
        continue
    if s=="WA":
        WA[p]+=1
    else:
        AC[p]=True
        panel+=WA[p]

ac=sum(AC)
print(ac,panel)

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())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

penal = 0
for p,s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA_cnt[p] += 1
    else:
        AC[p] = True
        penal += WA_cnt[p]

ac = sum(AC)
print(ac, penal)

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

Solution (Python):
N,M = map(int,input().split())
WAlist = [[0,"WA"]  for i in range(N)]
AC = WA = 0
for i in range(M):
    p,S = input().split()
    p = int(p)
    if S=="WA"and WAlist[p-1][1]=="WA":
        WAlist[p-1][0] += 1
    elif S=="WA" and WAlist[p-1][1]=="AC" or S=="AC"and WAlist[p-1][1]=="AC":
        continue
    elif S=="AC" and WAlist[p-1][1]=="WA":
        WAlist[p-1][1] = "AC"
        AC += 1

for j in range(N):
    if WAlist[j][1]=="AC":
        WA += WAlist[j][0]

print(AC,WA)

Solution (Python):
n, m = map(int, input().split())
li = list()
for i in range(m):
    li.append(tuple(input().split()))
 
ac_cnt = 0
wa_cnt = 0
 
s_ac = set()
d_wa = dict()
for l in li:
    if l[1] == 'AC':
        if l[0] not in s_ac:
            s_ac.add(l[0])
            ac_cnt += 1
            wa_cnt += d_wa.get(l[0], 0)
        else:
            pass
    elif l[1] == 'WA':
        d_wa[l[0]] = d_wa.get(l[0], 0) + 1
 
print(ac_cnt, wa_cnt)

Solution (Python):
n, m = map(int, input().split())
answer = [[False, 0] for _ in range(n)]
for i in range(m):
    number, result = input().split()
    number = int(number)
    if result == 'AC':
        answer[number-1][0] = True
    elif answer[number-1][0] != True:
        answer[number-1][1] += 1

ret = [ans[1] for ans in answer if ans[0] == True]
print(len(ret), sum(ret))

Solution (Python):
n, m = map(int, input().split())
p = [0]*m
s = [0]*m
fa = [0]*n
fw = [0]*n
for i in range(m):
    p[i], s[i] = input().split() 
p = [int(s) for s in p]

for i in range(m):
    if fa[p[i]-1] == 0:
        if s[i] == 'AC':
            fa[p[i]-1] = 1
        else:
            fw[p[i]-1] += 1
for i in range(n):
    if fa[i] == 0:
        fw[i] = 0
print(sum(fa), sum(fw))

Solution (Python):
n,m = map(int,input().split())
action = [list(input().split()) for _ in range(m)]
answer_dict = {}
score = 0
penalty = 0

for a in action:
    if a[1] == 'WA' and a[0] not in answer_dict:
        answer_dict[a[0]] = 1
    elif a[1] == 'WA' and answer_dict[a[0]] != 'Done':
        answer_dict[a[0]] += 1
    elif a[1] == 'AC':
        if a[0] in answer_dict and answer_dict[a[0]] != 'Done':
            score += 1
            penalty += answer_dict[a[0]]
            answer_dict[a[0]] = 'Done'
        elif a[0] not in answer_dict:
            score += 1
            answer_dict[a[0]] = 'Done'

print(score,penalty)

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())
correct = set()
penalty = 0
history = defaultdict(int)
for i in range(m):
    p, s = input().split()
    if s == "AC":
        correct.add(p)
        if history[p] != -1:
            penalty += history[p]
        history[p] = -1
    else:
        if history[p] != -1:
            history[p] += 1
print(len(correct), penalty)

Solution (Python):
from collections import OrderedDict
N, M = map(int, input().split())

correct = set()
wrong = OrderedDict()

for _ in range(M):
  p, s = input().split()
  pn = int(p)
  if pn not in wrong:
    wrong[pn] = 0
  if s == 'AC':
    if pn not in correct:
      correct.add(pn)
  elif s == 'WA':
    if pn not in correct:
      wrong[pn] += 1

print(len(correct), sum([wrong[pn] for pn in correct]))

Solution (Python):
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
ac = [False] * n
count = [0] * n
sum_wa = 0
for i in range(len(l)):
    
    if l[i][1] == "WA" and ac[int(l[i][0]) - 1] == False:
        count[int(l[i][0]) - 1] += 1
    elif l[i][1] == "AC":
        sum_wa += count[int(l[i][0]) - 1]
        count[int(l[i][0]) - 1] = 0
        ac[int(l[i][0]) - 1] = True
print(ac.count(True), sum_wa)

Solution (Python):
N,M = map(int,input().split())
ans = {}
for i in range(M):
    a,b = map(str, input().split() )
    if ans.get(a,0):
        ans[a].append(b)
    else:
        ans[a] = [b]
c = 0
p = 0
t = ans.values()
for line in t:
    k = 0
    for i in line:
        if i == "AC":
            c += 1
            p += k
            break
        else:
            k += 1
print(c,p)

Solution (Python):
n,m =map(int, input().split())
a =[list(input().split()) for i in range(m)]
ends = [0]*n
was = [0]*n
for num, kekka in a:
    num=int(num)-1
    if kekka=='AC':
        ends[num]=1
    else:
        if ends[num]!=1:
            was[num]+=1
for i in range(n):
    if ends[i]==0:
        was[i]=0
print(sum(ends), sum(was))

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

Solution (Python):
if __name__ == '__main__':
    n, m = list(map(int, input().split(' ')))
    ac_set = set([])
    num_list = []
    result_list = []
    counter = 0
    pena_dict = {}
    for i in range(m):
        num, result = input().split(' ')
        result_list.append(result)
        if result == 'AC':
            ac_set.add(num)
        elif (result == 'WA') and ((num in ac_set) is False):
            if (num in pena_dict) is False:
                pena_dict[num] = 1
            else:
                pena_dict[num] = pena_dict[num] + 1

    for i in ac_set:
        if i in pena_dict:
            counter = counter + pena_dict[i]

    print(len(ac_set), counter)

Solution (Python):
n, m = map(int, input().split())
li_q = list()
for i in range(m):
    li_q.append(tuple(input().split()))

ac_count = 0
wa_count = 0

s_ac = set()
d_wa = dict()
for l in li_q:
    if l[1] == 'AC':
        if l[0] not in s_ac:
            s_ac.add(l[0])
            ac_count += 1
            wa_count += d_wa.get(l[0], 0)
        else:
            pass
    elif l[1] == 'WA':
        d_wa[l[0]] = d_wa.get(l[0], 0) + 1

print(ac_count, wa_count)

Solution (Python):

import numpy as np
iNum, iM = map(int, input().split())
naB = np.zeros(iNum, dtype = "bool")
naW = np.zeros(iNum, dtype = int)
iC = 0
iW = 0
for _ in range(iM):
  l = input().split()
  iP = int(l[0]) - 1
  if not(naB[iP]):
    if l[1][0] == "A":
      naB[iP] = True
      iC += 1
      iW += naW[iP]
    else:
      naW[iP] += 1
print(iC, iW)

Solution (Python):
import sys
import math
import itertools
N,M=map(int,input().split())
result=[[0]*2 for _ in range(N)]
AC=0
pena=0
for _ in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=='AC':
        if result[p-1][1]==0:
            AC+=1
            result[p-1][1]=1
    else:
        if result[p-1][1]==0:
            result[p-1][0]+=1
for i in range(N):
    if result[i][1]==1:
        pena+=result[i][0]
print(AC,pena)

Solution (Python):

from collections import defaultdict
N, M = map(int, input().split())

d = defaultdict(list)
for i in range(M):
    p, S = input().split()
    d[int(p)].append(S)

a = 0
p = 0
for i in d.items():
    if 'AC' not in i[1]:
        continue

    ac_index = i[1].index('AC')
    a += 1

    if 'WA' in i[1]:
        wanum = i[1][:ac_index]
        p += len(wanum)

print(a, p)

Solution (Python):

n, m = map(int, input().split())
solved = {}
penalty = {}
for case in range(m):
    p, s = input().split()
    p = int(p)

    if s=='AC':
        solved[p] = True
    else: 
        if p in solved:
            continue 
        else:
            penalty[p] = penalty.get(p, 0) + 1

total_penalty = 0
for key in solved:
    total_penalty += penalty.get(key, 0)

print(len(solved), total_penalty)

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

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

ac_list = [0] * 10**6
wa_list = [0] * 10**6
for i in range(M):
    p, s = input().split()

    if ac_list[int(p)]:
        continue

    if s == "AC":
        ac_list[int(p)] = 1
        ac += 1
        wa += wa_list[int(p)]
    else:
        wa_list[int(p)] += 1

print(ac, wa)

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

str_l = ["WA"]*n
int_l = [0]*n
num = 0
ans = 0

for pp, s in ps:
    p = int(pp)-1
    if s == "AC":
        str_l[p] = "AC"
    else:
        if str_l[p] != "AC":
            int_l[p] += 1

for i in range(n):
    if str_l[i] == "AC":
        ans += int_l[i]
        num += 1

print(num,ans)

Solution (Python):

N,M = map(int,input().split())
ps = [list(map(str,input().split())) for _ in range(M)]

wacnt = [0]*(N+1)
is_ac = [False]*(N+1)
for pp,s in ps:
    p = int(pp)
    if s=='AC':
        is_ac[p] = True
    else:
        if not is_ac[p]:
            wacnt[p] += 1
num = 0
ans = 0
for l in range(N+1):
    if is_ac[l]:
       ans += wacnt[l]
       num += 1
       
print(num,ans)

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

problem_list = {}

for i in range(m):
    p, s = list(input().split())
    if p in problem_list.keys():
        if problem_list[p][1] == 1:
            continue
        else:
            if s == "AC":
                problem_list[p][1] += 1
            else:
                problem_list[p][0] += 1
    else:
        if s == "AC":
            problem_list[p] = [0, 1]
        else:
            problem_list[p] = [1, 0]
            
correct = 0
penalty = 0

for v in problem_list.values():
    p, c = v
    if c == 0:
        continue
    correct += c
    penalty += p
    
print(str(correct) + " " + str(penalty))

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

ac=[0 for i in range(n+1)]
ans=0
cle=0

for i in range(k):
    inp=input().split()
    p=int(inp[0])
    s=inp[1]
    if ac[p]>=0:
        if s=="AC":
            ans+=ac[p]
            ac[p]=-1
            cle+=1
        else:
            ac[p]+=1

print(cle,ans)