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 = list(map(int, input().split(' ')))
d = {}
ans_c = 0
ans_w = 0
for i in range(m):
    p, r = input().split(' ')
    if r == 'AC':
        if d.get(p) != 'finished':
            ans_c += 1
            ans_w += d.get(p, 0)
        d[p] = 'finished'
    elif d.get(p) != 'finished':
        d[p] = d.get(p, 0) + 1
print(ans_c, ans_w)

Solution (Python):
def resolve():
    N, M = list(map(int, input().split()))
    ACs = [0 for _ in range(N)]
    WAs = [0 for _ in range(N)]
    for _ in range(M):
        p, result = list(input().split())
        p = int(p)
        if result == "AC":
            ACs[p-1] += 1
        else:
            if ACs[p-1] == 0:
                WAs[p-1] += 1
    nac = 0
    nwa = 0
    for i in range(N):
        if ACs[i] >= 1:
            nac += 1
            nwa += WAs[i]
    print(nac, nwa)


if '__main__' == __name__:
    resolve()

Solution (Python):
N, M = map(int, input().split())
L = [list(input().split()) for _ in range(M)]
D_1 = {str(c):False for c in range(1, N+1)}
D_2 = {str(c):0 for c in range(1, N+1)}
for l in L:
  if l[1]=="WA" and D_1[l[0]]==False:
      D_2[l[0]] += 1 
  else:
    D_1[l[0]]=True
S_1 = sum(D_2[k] for k, v in D_1.items() if v)  
S_2 = sum(D_1.values())
print(S_2, S_1)

Solution (Python):
n,m = map(int,input().split())
wa = [0] * 10**6
ac = [0] * 10**6
ans = 0
for i in range(m):
    str_p,str_m = map(str,input().split())
    p = int(str_p)
    if str_m =='WA':
        if ac[p] == 0:
            wa[p] += 1
    else:
        if ac[p] == 0:
            ac[p] = 1
            ans += wa[p]
print(sum(ac),ans)

Solution (Python):
N, M = map(int, input().split())
ac = [False] * N
wa_cnt = [0] * N
ac_cnt = 0
for i in range(M):
    p, s = input().split()
    p_i = int(p) - 1
    if s == 'WA':
        if not ac[p_i]:
            wa_cnt[p_i] += 1
    else:
        if not ac[p_i]:
            ac[p_i] = True
            ac_cnt += 1

wa_cnt_sum = 0
for i in range(N):
    if ac[i]:
        wa_cnt_sum += wa_cnt[i]

print(ac_cnt,wa_cnt_sum)

Solution (Python):
import sys

def main():
    n,m = map(int, input().split())
    pn_list = [0]*n
    a = [0]*m
    b = [0]*m
    ans_ac = 0
    ans_pn = 0
    pn_list[0]== -1
    
    for i in range (m):
        a[i],b[i]=input().split()
        a[i] = (int(a[i]))
        
        if pn_list[a[i]-1] != -1:
            if b[i]== "AC":
                ans_pn += pn_list[a[i]-1]
                ans_ac +=1
                pn_list[a[i]-1] = -1 
            else:
                pn_list[a[i]-1] += 1

    print(ans_ac,ans_pn)
    
   
if __name__ == "__main__":
    main()

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

p = [0]*M
s = [0]*M
b = [0]*N
pena = 0
corr = 0

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

print(corr, pena)

Solution (Python):
n, m = map(int, input().split())
ac = [0] * n
wa = [0] * n
for _ in range(m):
    p, s = input().split()
    if s == 'AC':
        ac[int(p) - 1] = 1
    elif ac[int(p) - 1] == 0:
        wa[int(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())
ac_list = [0 for i in range(n+1)]
wa_list = [0 for i in range(n+1)]
p_list = []
ac = 0
pena = 0

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s == 'AC' and ac_list[p-1] != 1:
        ac += 1
        ac_list[p-1] = 1
        pena += wa_list[p-1]
    elif s == 'WA' and ac_list[p-1] != 1:
        wa_list[p-1] += 1

print(ac, pena)

Solution (Python):
n,m=[int(x) for x in input().split()]
Q=[0]*n
R=[0]*n
for i in range(m):
  P,s=input().split()
  p=int(P)
  if s=="AC" and Q[p-1]==0:
    Q[p-1]=1
  elif s=="WA" and Q[p-1]==0:
    R[p-1]+=1
ok=sum(Q)
for j in range(n):
  if Q[j]==0 and R[j]!=0:
    R[j]=0
bad=sum(R)
print(str(ok)+" "+str(bad))

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

Solution (Python):
n, m = map(int, input().split())
s = [[] for i in range(n)]
for i in range(m):
    p, S = input().split()
    s[int(p) - 1] += [S]
print(sum('AC' in si for si in s), sum(si[:si.index('AC')].count('WA') if 'AC' in si else 0 for si in s))

Solution (Python):
n, m = map(int, input().split())
s = [[] for i in range(n)]
for i in range(m):
    p, S = input().split()
    s[int(p) - 1] += [S]
print(sum('AC' in si for si in s), end=' ')
print(sum(si[:si.index('AC')].count('WA') if 'AC' in si else 0 for si in s))

Solution (Python):
def solve():
    N,M = [int(i) for i in input().split()]
    solved = set([])
    penalty = {}
    for i in range(M):
        problem_id,result = input().split()
        if result == 'AC':
            solved.add(problem_id)
        elif result == 'WA' and problem_id not in solved:
            penalty[problem_id] = penalty.get(problem_id, 0) + 1
    num_penalties = 0
    for problem_id in solved:
        num_penalties += penalty.get(problem_id, 0)
    print(len(solved), num_penalties)


if __name__ == "__main__":
    solve()

Solution (Python):
n,m=map(int,input().split())
a=0
p=0
L=[0 for _ in range(n)]
for _ in range(m):
  num,s = input().split()
  num=int(num)-1
  if not L[num] == -1:
    if s == "AC":
      a+=1
      p+=L[num]
      L[num]=-1
    else:
      L[num]+=1
print(a,p)

Solution (Python):
n,m=map(int,input().split())
res=[[]for _ in range(n+1)]
a=0
w=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    res[p].append(s)

for i in range(1,n+1):
    if "AC" in res[i]:
        a+=1
        f=0
        for j in range(len(res[i])):
            if res[i][j]=="WA" and f==0:
                w+=1
            if res[i][j]=="AC":
                f=1
        
print(a,w)

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

if m == 0:
  print(0,0)
  exit(0)

results=[]
for i in range(n+1):
  results.append([0,0])
  
ac = 0
wa = 0
memo = [0]*(n+1)
for i in range(m):
  p,s=input().split()
  p = int(p)
  s = s.strip()

  if memo[p] != -1:
    if s == 'WA':
      memo[p] += 1
    else:
      ac += 1
      wa += memo[p]
      memo[p] = -1

print(ac,wa)

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

print(sum(listAC), sum(listWAAC))

Solution (Python):
NN, MM = list(map(int,input().split()))
ARR = [list(input().split()) for l in range(MM)]

bin = [0]*NN
done = [0]*NN

for ind in range(MM):
    if done[int(ARR[ind][0])-1] == 0:
        if ARR[ind][1] == 'WA':
            bin[int(ARR[ind][0])-1] += 1
        else:
            done[int(ARR[ind][0])-1] = 1

cbin = [x * y for (x,y) in zip(done,bin)]
print(sum(done), sum(cbin))

Solution (Python):
def resolve():
    n, m = map(int, input().split())
    co = 0
    pe = 0
    P = [0] * n
    for _ in range(m):
        p, s = input().split()
        ind = int(p)-1
        if P[ind] != -1: 
            if s == "WA":
                P[ind] += 1
            else:
                pe += P[ind]
                P[ind] = -1
                co += 1
    print(co, pe)
resolve()

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

correct = 0
penalty = 0
for ll in l:
    if 'AC' not in ll:
        continue
    correct += 1
    penalty += ll.index('AC')

print(correct, penalty)

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

correct = 0
penalty = 0
for ll in l:
    if 'AC' not in ll:
        continue

    correct += 1
    penalty += ll.index('AC')

print(correct, penalty)

Solution (Python):
n, m = map(int, input().split())
submissions = [list(input().split()) for _ in range(m)]
count_penalty = [0] * (n + 1)
count_ac = [0] * (n + 1)

for i in range(m):
    ploblem = int(submissions[i][0])
    if submissions[i][1] == "AC":
        count_ac[ploblem] = 1

    elif count_ac[ploblem] != 1 and submissions[i][1] == "WA":
        count_penalty[ploblem] += 1

for i in range(n + 1):
    if count_ac[i] != 1:
        count_penalty[i] = 0

print("{} {}".format(count_ac.count(1), sum(count_penalty)))

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

n,m=map(int,input().split())
ans=0;wrong=0
d=[0]*n
for i in range(m):
    p,s=input().strip().split()
    p=int(p)-1
    if d[p]!=-1:
        if s=='WA':
            d[p]+=1
        else:
            wrong+=d[p]
            d[p]=-1
            ans+=1
print(ans,wrong)

Solution (Python):
N,M = map(int,input().split())
d,ans,wrong = [0]*N,0,0
for _ in range(M):
    p,s = input().split()
    p = int(p)-1
    if d[p] != -1:
        if s == "WA":
            d[p] += 1
        else:
            wrong += d[p]
            d[p] = -1
            ans += 1
print(ans,wrong)

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

acli = [0]*N
wali = [0]*N

for _ in range(M):
  P,S = map(str,input().split())
  P = int(P)-1
  if acli[P] == 1:
    continue
  if S == "AC":
    acli[P] = 1
  else:
    wali[P] += 1
    
for i in range(N):
  if acli[i] == 0:
    wali[i] = 0
    
print(sum(acli),sum(wali))

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

prob = [[0] * 2 for _ in range(N + 1)]

ps_list = [[0, 0]]

for i in range(1, M + 1):
    p, s = input().split()
    p = int(p)
    ps_list.append([p, s])
    if s == "AC" and prob[p] == [0, 0]:
        prob[p] = [1, i]




ac = 0
for item in prob:
    if item[0] == 1:
        ac += 1

penalty = 0
for i in range(1, M + 1):
    p = ps_list[i][0]
    s = ps_list[i][1]
    if s == "WA" and i < prob[p][1]:
        penalty += 1

print(ac, penalty)

Solution (Python):
N,M = map(int,input().split())
correct = [0]*N
penalty = [0]*N
ans_c,ans_p = 0,0
for i in range(M):
    p,s = input().split()
    p = int(p)
    if s=="AC":
        if correct[p-1]==0:
            correct[p-1]+=1
    if s=="WA":
        if correct[p-1]==0:
            penalty[p-1]+=1

ans_penalty = 0
for i in range(N):
    if correct[i]>=1:
        ans_penalty+=penalty[i]
print(sum(correct),ans_penalty)

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

ac =[0]*(n+1)
wa =[0]*(n+1)
for i in range(m):
    question =int(p[i][0])
    
    if p[i][1] == "AC" and ac[question] == 0:
        ac[question] = 1
     
    elif p[i][1] == "WA" and ac[question] == 0:
        wa[question] += 1
for j in range(n+1):
  
    if ac[j] == 0:
        wa[j] = 0
       
print(sum(ac),sum(wa))

Solution (Python):
n,m = map(int,input().split())
p = [list(map(str,input().split())) for _ in range(m)]
ac =[0]*(n+1)
wa =[0]*(n+1)
for i in range(m):
    question =int(p[i][0])
    if p[i][1] == "AC" and ac[question] == 0:
        ac[question] = 1
    elif p[i][1] == "WA" and ac[question] == 0:
        wa[question] += 1
for j in range(n+1):
    if ac[j] == 0:
        wa[j] = 0
       
print(sum(ac),sum(wa))

Solution (Python):
n,m=map(int,input().split())
d,c,wa=[0]*n,0,0
for _ in range(m):
    p,a=input().split()
    p=int(p)-1
    if d[p]!=-1:
        if 'W' in a:
            d[p]+=1
        else:
            wa+=d[p]
            d[p]=-1
            c+=1
print(c,wa)

Solution (Python):
n,m=map(int,input().split())
data=[0]*n
count,wa=0,0
for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if type(data[p]) is int:
        if a=='WA':
            data[p]+=1
        else:
            wa+=data[p]
            data[p]=''
            count+=1
print(count,wa)

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

data=[0]*n
s=set()
sum_wa=0

for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if p in s:
        continue
    else:
        if a=='WA':
            data[p]+=1
        else:
            sum_wa+=data[p]
            s.add(p)

print(len(s),sum_wa)

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

data=[0]*n
s=set()

for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if p in s:
        continue
    else:
        if a=='WA':
            data[p]-=1
        else:
            data[p]*=-1
            s.add(p)

print(len(s),sum([data[i] for i in range(n) if data[i]>0]))

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

sum_wa=0
data=[0]*n

for i in range(m):
    if p[i][0] in correct and data[int(p[i][0])-1]==0:
        if p[i][1]=='WA':
            sum_wa+=1
        else:
            data[int(p[i][0])-1]=1

print(sum(data),sum_wa)

Solution (Python):
N,M = map(int,input().split())
wa_list= [0]*(N+2)
ac_list=[-1]*(N+2)
for i in range(M):
  p,a = map(str,input().split())
  p = int(p)
  if a =='WA':
    wa_list[p]+=1
  if a =='AC' and ac_list[p] == -1:
    ac_list[p]+=(wa_list[p]+1)
count = 0;count2 = 0
for i in ac_list:
  if i>=0:
    count+=1
    count2+=i
print(count,count2)

Solution (Python):
N,M = map(int,input().split())
wa_list= [0]*(N+2)
ac_list=[-1]*(N+2)
for i in range(M):
  p,a = map(str,input().split())
  p = int(p)
  if a =='WA':
    wa_list[p]+=1
  if a =='AC' and ac_list[p] == -1:
    ac_list[p]+=(wa_list[p]+1)
count = 0;count2 = 0
for i in ac_list:
  if i>=0:
    count+=1
    count2+=i
print(count,count2)

Solution (Python):
N,M = map(int,input().split())
wa_list= [0]*(N+2)
ac_list=[-1]*(N+2)
for i in range(M):
  p,a = map(str,input().split())
  p = int(p)
  if a =='WA':
    wa_list[p]+=1
  if a =='AC' and ac_list[p] == -1:
    ac_list[p]+=(wa_list[p]+1)
    


count = 0
count2 = 0
for i in ac_list:
  if i>=0:
    count+=1
    count2+=i
print(count,count2)

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

s=set()
sum_wa=0

for i in [p[j] for j in range(m) if p[j][0] in correct]:
    if i[0] in s:
        continue
    else:
        if i[1]=='WA':
            sum_wa+=1
        else:
            s.add(i[0])

print(len(correct),sum_wa)

Solution (Python):
n,m=map(int,input().split())
lst=[list(input().split()) for i in range(m)]
x,y=0,0
cnt=['?']+[0]*n
cnt2=[0]+[0]*n
for i in lst:
  if i[1]=='WA':
    pin=int(i[0])
    if cnt[pin]!='AC':
      cnt2[pin]+=1
  elif i[1]=='AC':
    cnt[int(i[0])]='AC'

x=cnt.count('AC')

for i in range(len(cnt)):
  if cnt[i]=='AC':
    y+=cnt2[i]
print(x,y)

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

for i in range(N):
  progress[str(i+1)] = ["notCorrect",0]
correct = 0

for i in range(M):
  question, result = map(str, input().split())
  if (progress[question][0] == "notCorrect"):
    if (result == "WA"):
      progress[question][1] += 1
    else:
      progress[question][0] = "correct"
      correct += 1
  else:
    continue
penalty = 0
for i in range(N):
  if (progress[str(i+1)][0] == "correct"):
    penalty += progress[str(i+1)][1]
print(str(correct)+" "+str(penalty))

Solution (Python):
def readinput():
    n,m=map(int,input().split())
    tries=[]
    for _ in range(m):
        p,s=input().split()
        p=int(p)
        tries.append((p,s))
    return n,m,tries

def main(n,m,tries):
    point=[[0,0] for i in range(n+1)]
    for i in range(m):
        p,s=tries[i]
        if s=='WA':
            if point[p][0]>0:
                continue
            else:
                point[p][1]+=1
        else:
            point[p][0]+=1
    ac=0
    wa=0
    for i in range(1,n+1):
        if point[i][0]>0:
            ac+=1
            wa+=point[i][1]
    
    return ac,wa

if __name__=='__main__':
    n,m,tries=readinput()
    ans=main(n,m,tries)
    print(' '.join(map(str,ans)))

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

maru = [0]*n
pena = [0]*n

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

penapena = [maru[i]*pena[i] for i in range(n)]

print(maru.count(1),sum(penapena))

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()

    isACed = [0] * n
    submmited = [0] * n

    for i in range(m):
        p, res = input().split()
        p = int(p)
        if isACed[p - 1] == 0 and res == "WA":
            submmited[p - 1] += 1

        if res == "AC":
            isACed[p - 1] = 1
    acs = 0
    was = 0
    for i in range(n):
        if isACed[i] == 1:
            acs += 1
            was += submmited[i]

    print(acs, was, sep=" ")


main()

Solution (Python):

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



ans = 0


F = [False] * (N+1)
pen = 0
P = [0] * (N+1)
for i in range(M):
    p, s = map(str,input().split())
    p = int(p)
    if s == "WA" and not F[p]:
        P[p] += 1
    if s == "AC" and not F[p]:
        ans += 1
        pen += P[p]
        F[p] = True

print(ans, pen)

Solution (Python):
N, M = map(int, input().split())
data = [0]*N
solved = [False]*N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if solved[p] == False and S == "WA":
        data[p] += 1
    if solved[p] == False and S == "AC":
        solved[p] = True

print(sum(solved),sum( x*y for x, y in zip(data, solved)) )

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

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

print(ac,wa)

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n,m = [int(x) for x in stdin.readline().rstrip().split()]

check = [0 for i in range(n)]
count = [0 for i in range(n)]

for i in range(m):
    p, q = [x for x in stdin.readline().rstrip().split()]
    p = int(p)

    if q == 'AC':
        check[p-1] = 1

    if q == 'WA' and check[p-1] == 0:
        count[p-1] = count[p-1] + 1

for i in range(n):
    if check[i] == 0: count[i] = 0

print(sum(check), sum(count))

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


for i in range(M):
    
    
    p, S = map(str,input().split())
    p = int(p)-1
    if S == "AC" and AC_list[p] == 0:
        AC_list[p] = 1
    elif S == "WA" and AC_list[p] == 0:
        WA_list[p] +=1
    else:
        continue

for i in range(N):
    if AC_list[i] == 0:
        WA_list[i] = 0

print("{} {}".format(sum(AC_list), sum(WA_list)))

Solution (Python):
n,m=map(int,input().split())
ans = [0]*n
tmp = [0]*n
pen = [0]*n
for i in range(m):
  inp = input().split()
  if inp[1] == "AC":
    ans[int(inp[0])-1] = 1
    pen[int(inp[0])-1] = tmp[int(inp[0])-1]
  elif inp[1] == "WA":
    if ans[int(inp[0])-1] == 0:
      tmp[int(inp[0])-1] += 1
        
print("{0} {1}".format(sum(ans),sum(pen)))

Solution (Python):
n,m = map(int,input().split())
memo2 = [False for i in range(n)]
memo = [0 for i in range(n)]
count1,count2 = 0,0
for i in range(m):
    p,l = input().split()
    p = int(p)-1
    if memo2[p]:
        continue
    else:
        if l == 'WA':
            memo[p]+=1
        else:
            memo2[p] = True
            count2 += 1
            count1+=memo[p]
print(count2,count1)

Solution (Python):
n, m = map(int, input().split())
S = [[] for _ in range(n)]
pe = [0] * n
co = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    S[p] += [s]
for i, s_ in enumerate(S):
    if all(j == 'WA' for j in s_):
        continue
    for s in s_:
        if s == 'AC':
            co[i] = 1
            break
        else:
            pe[i] += 1
print(sum(co), sum(pe))

Solution (Python):
(N,M),*ps = [s.split() for s in open(0)]

ps = [(int(p),s=='WA') for p,s in ps]

from collections import Counter
cnt = Counter()
acs = set()

for p,s in ps:
    if p not in acs:
        if s:
            cnt[p] += 1
        else:
            acs.add(p)
a = len(acs)
b = sum(cnt[ac] for ac in acs)
print(a,b)

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

solved = [False] * n
ac_cnt = 0
wa_l = [0] * n

for i in range(m):
    cn, cj = int(a[i][0]) - 1, a[i][1]
    if not solved[cn]:
        if cj == 'WA':
            wa_l[cn] += 1
        else:
            ac_cnt += 1
            solved[cn] = True
wa_cnt = 0
for i in range(n):
    wa_cnt += solved[i] * wa_l[i]
print(ac_cnt, wa_cnt)

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

flag = [False]*n
nums = [0]*n
for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == "AC": flag[p] = True
  elif flag[p] == False: nums[p] += 1
ac = flag.count(True)
wa = 0
for i in range(n):
  if flag[i]: wa += nums[i]
print(ac, wa)

Solution (Python):
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()


N, M = inpl()
ac = [False] * (N+10)
wa = [0] * (N+10)

a = 0
w = 0
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'WA':
        if not ac[p]:
            wa[p] += 1
    else:
        if not ac[p]:
            ac[p] = True
            a += 1
            w += wa[p]

print(a, w)


ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Solution (Python):
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()


N, M = inpl()
ac = [False] * (N+10)
wa = [0] * (N+10)

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

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

print(a, w)


ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

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

pena = [0]*(10**5 + 1)

wa = 0
ac = 0

for i in range(m):
    p, s = map(str, input().split())
    if s == "WA" and pena[int(p)] != -1:
        pena[int(p)] += 1
    elif s == "WA" and pena[int(p)] == -1:
        continue
    elif s == "AC" and pena[int(p)] == -1:
        continue
    else:
        ac += 1
        wa += pena[int(p)]
        pena[int(p)] = -1

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


N,M= LI()
if M==0:
    print(0,0)
    exit()
pS = [LS() for _ in range(M)]


_p,S = zip(*pS)

p = list(map(int,_p))

WA = np.zeros(N+1)
AC = np.full(N+1,False, dtype=bool)

penalty = 0
for i in range(M):
    if AC[p[i]]:
        continue
    if S[i]=='WA':
        WA[p[i]] += + 1
    else:
        AC[p[i]]=True
        penalty += WA[p[i]]        

AC_count = np.count_nonzero(AC)        


print(AC_count,int(penalty))

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

for i in range(m):
  p,s = input().split()
  p = int(p)
  if p in d:
    if d[p] == 'AC':
      pass
    else:
      if s == 'AC':
        d[p] = 'AC'
        ac += 1
        wa_sum += wa[p]
      else:
        wa[p] += 1
  else:
    d[p] = s
    if s == 'AC':
      ac += 1
    else:
      wa[p] += 1

print(ac,wa_sum)

Solution (Python):
N,M = map(int,input().split())
ls2 = []
for i in range(M):
    A,B = map(str,input().split())
    ls = [int(A)-1,B]
    ls2.append(ls)

Pena = 0
corr = 0


lsans = [[] for i in range(N)]
for i in range(M):
    lsans[ls2[i][0]].append(ls2[i][1])

for i in range(N):
    if 'AC' in lsans[i]:
        for ans in lsans[i]:
            if ans == 'WA':
                Pena += 1
            if ans == 'AC':
                corr += 1
                break
print(corr,Pena)

Solution (Python):
N, M = map(int, input().split())
ac = 0
is_AC = [False] * (N + 1)
WA_cnt = [0] * (N + 1)
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if is_AC[p]:
            continue
        else:
            WA_cnt[p] += 1
    else:
        if is_AC[p]:
            continue
        else:
            is_AC[p] = True
            ac += 1

wa = 0
for i in range(N + 1):
    if is_AC[i]:
        wa += WA_cnt[i]
print(ac, wa)
'''
うまくいかなかったパターン
1 4
1 WA
1 WA
1 WA
1 WA
'''

Solution (Python):
N, M = [int(n) for n in input().split()]
solved = {}
result = {}

for i in range(M):
    p, S = input().split()
    status = result.setdefault(p, [])
    if len(status)==0:
        result[p] = []
        solved[p] = False
    if S == 'AC':
        solved[p] = True
    result[p].append(S)

ans = 0
wa = 0
for k, v in solved.items():
    if v:
        ans += 1
        wa += result[k].index('AC')
print(ans , wa)

Solution (Python):
N,M=map(int,input().split()) 
L=[list(input().split()) for i in range(M)]
W=[0]*N
A=[0]*N
a=0
w=0
for i in range(M):
  if L[i][1]=="AC":
    A[int(L[i][0])-1]=1
    
  elif L[i][1]=="WA" and A[int(L[i][0])-1]==0:
    W[int(L[i][0])-1]+=1

  

  
for i in range(N):
  if A[i]>0:
    a+=1
    w+=W[i]
print(a,w)

Solution (Python):
n,m=map(int,input().split())
aa=[[] for i in range(n)]
for x in range(m):
  a,b=input().split()
  d=int(a)-1
  aa[d].append(b)

ac=0
wa=0
for i in range(n):
    a1=0
    a2=0
    for j in range(len(aa[i])):
        if aa[i][j]=="WA":
            a1+=1
        else:
            a2+=1
            break
    if a2==1:
        wa+=a1
        ac+=1
print(str(ac)+" "+str(wa))

Solution (Python):
N,M=map(int,input().split())
wa=[0]*N
pen=[0]*N
ac=[0]*N
for x in range(M):
  P,S=input().split()
  if S=="WA" and ac[int(P)-1]==0:
    wa[int(P)-1] += 1
  elif S=="AC" and ac[int(P)-1]==0:
    ac[int(P)-1] += 1
    pen[int(P)-1] = wa[int(P)-1]
print(f"{sum(ac)} {sum(pen)}")

Solution (Python):
n,m=map(int,input().split())
aa=[[] for i in range(n)]
for x in range(m):
  a,b=input().split()
  d=int(a)-1
  aa[d].append(b)
  
ans_ac=0
ans_wa=0
for y in range(n):
  ans1=0
  ans2=0
  for z in range(len(aa[y])):
    if aa[y][z]=='WA':
      ans1+=1
    else:
      ans2+=1
      break
  if ans2==1:
    ans_wa+=ans1
    ans_ac+=1
    
print(str(ans_ac)+' '+str(ans_wa))

Solution (Python):
n,m=map(int,input().split())
aa=[[] for i in range(n)]
for x in range(m):
  a,b=input().split()
  d=int(a)-1
  aa[d].append(b)
  
ans_ac=0
ans_wa=0
for y in range(n):
  ans1=0
  ans2=0
  for z in range(len(aa[y])):
    if aa[y][z]=='WA' and ans2==0:
      ans1+=1
    elif aa[y][z]=='AC' and ans2==0:
      ans2+=1
      
  if ans2==1:
    ans_wa+=ans1
    ans_ac+=1
    
print(str(ans_ac)+' '+str(ans_wa))

Solution (Python):
n, m = map(int, input().split())
ans_dict = {}
for _ in range(m):
    p, s = input().split()
    if p not in ans_dict:
        ans_dict[p] = [s]
    else:
        ans_dict[p].append(s)

ac_cnt = 0
wa_cnt = 0

ac_ans = 0
wa_ans = 0

for key in ans_dict.keys():
    ac_cnt = ans_dict[key].count('AC')
    wa_cnt = ans_dict[key].count('WA')
    if ac_cnt != 0:
        ac_ans += 1
        
        ac_index = ans_dict[key].index('AC')
        wa_ans += ans_dict[key][:ac_index].count('WA')
    
print(ac_ans, wa_ans)

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

wa_num = 0
ac_num = 0

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

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

    if AC[p]:
        continue

    if S == "AC":
        AC[p] = True
        ac_num += 1
        wa_num += WA[p]
    elif S == "WA":
        WA[p] += 1

print(f"{ac_num} {wa_num}")

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

ac_count = 0
wa_count = 0
data = {}
for _ in range(M):
  p, s = input().split()
  if p in data:
    if data[p][AC] == 1:
      
      continue
  if s == "AC":
    if p in data:
      wa_count += data[p][WA]
    ac_count += 1
    data[p] = [1, 0]
  if s == "WA":
    if p in data:
      data[p][WA] += 1
    else:
      data[p] = [0, 1]

print(ac_count, wa_count)

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

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

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

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

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

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

print(AC_cnt,WA_cnt)

Solution (Python):
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, M = MI()

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

    ans = [0]*(N+1)
    error = [0]*(N+1)
    e = [0]*(N+1)

    for i in range(M):
        if ans[int(p[i])] == 0:
            if S[i] == "WA":
                error[int(p[i])] += 1
            elif S[i] == "AC":
                ans[int(p[i])] = 1

    sum_ans = sum(ans)
    sum_error = 0
    for i in range(N+1):
        if ans[i] == 1:
            sum_error += error[i]
    print(sum_ans, sum_error)

if __name__ == "__main__":
	main()