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):
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()

    if ans is True or ans is False:
        YesNo(ans)
    elif ans is not None:
        print(ans)


def solve():
    N, M = iip(False)
    A = iipt(M)
    d = {}

    for p, s in A:
        d[p] = [0, 0]

    for p, s in A:
        if d[p][1] == 1:
            continue
        elif s == "WA":
            d[p][0] += 1
        else:
            d[p][1] = 1

    e = 0
    f = 0
    for a, b in d.values():
        if b == 0:
            continue
        e += a
        f += b

    split_print_space([f, e])



def kiriage_warizan(a, b):
    return -(-a//b)


def iip(listed=True):  
    d = input().split()
    try:
        ret = [int(i) for i in d]
    except:
        ret = [int(i) if i in _NUMINT_ALL else i for i in d]
        if len(ret) == 1:
            return ret[0]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iipt(l, listed=False, num_only=True):  
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed))
    return ret


def saidai_kouyakusuu(A):  
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def make_graph_edge_flat(N):  
    ret = []
    for i in range(N-1):
        a, b, c = iip()
        a -= 1
        b -= 1
        ret[a].append((b, c))
        ret[b].append((a, c))
    return ret


def sort_tuples(l, index):  
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  
    if index >= len(l):                      
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def sortstr(s):  
    return "".join(sorted(s))


def iip_ord(startcode="a"):  
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  
    for i in s:
        print(i)


def bitall(N):  
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):  
    return power(n, mod - 2)


def power(n, p, mod_=mod):  
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


def nibutan_func(func, target, left, right, side="left"): 
    l = left
    r = right
    while r-l > 1:
        x = (l+r)//2
        if func(x) == target:
            return x
        elif func(x) > target:
            r = x
        else:
            l = x

    if side == "left" or func(x) == target:
        return l
    else:
        return r


def nibutan_list(list_, target, side="left"):  
    if not isinstance(list_, list):
        list_ = list(list_)

    l = 0
    r = len(list_)
    while r-l > 1:
        x = (l+r)//2
        if list_[x] == target:
            return x
        elif list_[x] > target:
            r = x
        else:
            l = x

    if side == "left" or list_[x] == target:
        return l
    else:
        return r

if __name__ == "__main__":
    main()

Solution (Python):
def main(n: int, m: int, p_s: list):
    bool_ac = [False for _ in range(n)]
    count_wa = [0 for _ in range(n)]
    ac, wa = 0, 0

    for p, s in p_s:
        p = int(p)

        if bool_ac[p - 1]:
            continue

        if s == "AC":
            bool_ac[p - 1] = True
            wa += count_wa[p - 1]
            ac += 1
        elif s == "WA":
            count_wa[p - 1] += 1

    print(ac, wa)


if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [input().split() for _ in range(m)]

    main(n, m, p_s)

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


dict_ac = {i:0 for i in range(N)}
dict_wa = {i:0 for i in range(N)}


number = True
index = 0
for i, j in lists:

    if j == "WA":
        i = int(i) - 1
        if dict_ac[i] == 0:
            dict_wa[i] += 1

    elif j == "AC":
        if i not in dict_ac.keys():
            i = int(i) - 1
            dict_ac[i] = 1






for i in dict_wa.keys():
    if dict_ac[i] == 0:
        dict_wa[i] = 0
    else:
        continue




print(sum(dict_ac.values()), sum(dict_wa.values()))

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

ac = [0] *N
pena = [0] *N

for _ in range(M):
    P, S = map(str, input().split())
    P = int(P) - 1
    if ac[P]: continue
    if S == 'AC':
        ac[P] = 1
    else:
        pena[P] += 1

AC = 0
PENA = 0

for i in range(N):
    AC += ac[i]
    if ac[i]:
        PENA += pena[i]

print('{} {}'.format(AC, PENA))

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

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

Solution (Python):
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))


n, m = load_list()

ac = dict()
pena = defaultdict(int)
a, b = 0, 0
for _ in range(m):
    p, r = input().split(" ")
    p = int(p)
    r = r.strip()
    if r == 'AC' and p not in ac:
        a += 1
        ac[p] = 1
        b += pena[p]
    elif r == 'WA' and p not in ac:
        pena[p] += 1

print(a,b)

Solution (Python):
N,M = map(int, input().split())
A = {}
C = 0
P = 0
for i in range(M):
    p,S = map(str, input().split())
    if S == 'AC' and A.get(p+S) is None:
        A[p+S] = 0
        C += 1
    elif S == 'WA' and A.get(p+'AC') is None and A.get(p+S) is None:
        A[p+S] = 1
    elif S == 'WA' and A.get(p+'AC') is None:
        A[p+S] += 1
for i in range(1,N+1):
    if A.get(str(i)+'AC') is not None and A.get(str(i)+'WA') is not None:
        P += A[str(i)+'WA']
print(C,P)

Solution (Python):
N, M = map(int, input().split())
ACs = [0] * N
wa = 0
ac = 0
for _ in range(M):
    p, s = input().split()
    if s == "WA" and ACs[int(p)-1] <= 0:
        ACs[int(p)-1] -= 1
    if s == "AC" and ACs[int(p)-1] <= 0:
        wa -= ACs[int(p)-1]
        ACs[int(p)-1] = 1
        ac += 1
print("{} {}".format(ac, wa))

Solution (Python):
import numpy as np


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

Check_AC = np.zeros(N)
WA_Counter = np.zeros(N)

for i in range(M):
    pi,Si = input().split()
    pi = int(pi)
    
    if Check_AC[pi-1] == 0:
        if Si == "AC":
            Check_AC[pi-1] = 1
        else:
            WA_Counter[pi-1] += 1
    
print(str(int(sum(Check_AC))) + " " + str(int(np.dot(Check_AC,WA_Counter))))

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

Solution (Python):
from collections import defaultdict

a,b = map(int,input().split())

k=defaultdict(lambda:defaultdict(int))

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

    if k[p].get('AC'):
        continue

    k[p][s] += 1

x = y = 0

for i,j in k.items():
    if j.get('AC'):
        x+=1
        if j.get('WA'):
            y+=j['WA']

    


print(x,y)

Solution (Python):
n, m = map(int, input().split())
lis = [list(input().split()) for _ in range(m)]
d = {}
ac, wa = 0, 0
for i in lis:
    if i[0] not in d:
        if i[1] == 'AC':
            ac += 1
            d[i[0]] = 'AC'
        else:
            d[i[0]] = 1
    else:
        if i[1] == 'AC':
            if d[i[0]] != 'AC':
                ac += 1
                wa += d[i[0]]
                d[i[0]] = 'AC'
        else:
            if d[i[0]] != 'AC':
                d[i[0]] += 1
print(ac, wa)

Solution (Python):
n, m = (int(i) for i in input().split());

task = [[0, 0] for i in range(n)];
solved = 0;
penalty = 0;

for i in range(m):
    p, s = (j for j in input().split());
    p = int(p) - 1;
    if task[p][0] == 1:
        continue;
    if s == "AC":
        solved += 1;
        penalty += task[p][1];
        task[p][0] = 1;
    else:
        task[p][1] += 1;

print(solved, penalty);

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

memo=set()
ACcount=0
PEcount={}
for _ in range(m):
	p,s=input().split()
	if p not in memo:
		if s=="AC":
			ACcount+=1
			memo.add(p)
		else:
			if p in PEcount:
				PEcount[p]+=1
			else:
				PEcount[p]=1
count=0
for i in memo:
	if i in PEcount:
		count+=PEcount[i]
print("{} {}".format(ACcount,count))

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

for _ in range(M):
  x = input().split()
  p = int(x[0])
  S = x[1]
  if S == "AC":
    L[p-1][0] = 1
  elif L[p-1][0] == 0:
    L[p-1][1] +=1

ac = 0
wa = 0
for i in range(N):
    x = L[i][0]
    y = L[i][1]
    if x == 1:
        ac +=1
        wa +=y
        
print(ac,wa)

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

a=[0]*n
w=[0]*n

ac=0
wa=0

for i in range(m):

  p,s=map(str,input().split())
  p=int(p)

  if a[p-1]==0:
    if s=="AC":
      ac+=1
      wa+=w[p-1]
      a[p-1]=1
    else:
      w[p-1]+=1

print(ac,wa)

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())
ac_set = set()
wa_dic = defaultdict(int)
wa_cnt = 0
for i in range(m):
    p, s = input().split()
    if s == 'AC':
        ac_set.add(p)
    else:
        if p not in ac_set:
            wa_dic[p] += 1
print(len(ac_set), sum(value for key, value in wa_dic.items() if key in ac_set))

Solution (Python):
n, m = map(int, input().split())
p = [0 for i in range(m)]
s = ["WA" for i in range(m)]
correct = [0 for i in range(n)]
penalty = [0 for i in range(n)]
for i in range(m):
    temp = input().split()
    p[i], s[i] = int(temp[0]), temp[1]
for i, j in zip(p, s):
    if j == "AC":
        correct[i-1] = True
    else:
        if not correct[i-1]:
            penalty[i-1] += 1
a = 0
b = 0
for i, j in zip(correct, penalty):
    if i:
        a += 1
        b += j
print(a, b)

Solution (Python):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
problems = [False] * N
AC = [0] * N
WA = [0] * N
for _ in range(M):
    p, S = sr().split(); p = int(p) - 1
    if not problems[p] and S == 'WA':
        WA[p] += 1
    if not problems[p] and S == 'AC':
        problems[p] = True
        AC[p] += 1

AC_total = sum(AC)
WA_total = sum(y for x, y in zip(AC, WA) if x)
print(AC_total, WA_total)

Solution (Python):

n, m = map(int, input().split())
ac = 0
wa = 0
tmp = {}
d = set()
for _ in range(m):
    p, s = map(str, input().split())
    if p not in tmp:
        tmp[p] = 0
    if p not in d and s == "AC":
        d.add(p)
        ac += 1
        if p in tmp:
            wa += tmp[p]
    if p not in d and s == "WA":
        tmp[p] += 1
print(ac, wa)

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

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

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)

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

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

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)

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

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

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)

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

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

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)

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

Solution (Python):
import sys

N, M = map(int, input().split(" "))
pen = [0 for i in range(N)]
ans = [False for i in range(N)]
num_pen = 0

for i in range(M):
    p, S = input().split(" ")
    if S == 'AC':
        if not ans[int(p) - 1]:
            num_pen += pen[int(p) - 1]
        ans[int(p) - 1] = True
    elif S == 'WA':
        pen[int(p) - 1] += 1
    else:
        sys.stderr('input error')
print(sum(ans), num_pen)

Solution (Python):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect




from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n,m = map(int, readline().split())
  p = [0]*m
  s = ['']*m
  count = [0]*n
  AC = [0]*n
  for i in range(m):
    tmp, s[i] = input().split()
    p[i] = int(tmp)
  for i in range(m):
    if AC[p[i]-1]==0:
      if s[i]=='WA':
        count[p[i]-1] += 1
      else:
        AC[p[i]-1] = 1
  penalty = 0
  for i in range(n):
    if AC[i]==1:
      penalty += count[i]
  print('{} {}'.format(sum(AC),penalty))
  
  
  
if __name__ == '__main__':
  main()

Solution (Python):
n, m = [int(i) for i in input().split()]
ac = [0] * n
wa = [0] * n

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

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

print(sum(ac), wa_sum)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    n,m = map(int, input().split())
    result = [0]*n
    wa = [0]*n
    ac = [0]*n
    for _ in range(m):
        i = input().rstrip()
        i = i.split()
        p, s = int(i[0]), i[1]
        if s=='WA':
            if result[p-1]==0:
                wa[p-1] += 1
        else:
            if result[p-1]==0:
                result[p-1] = 1
                ac[p-1] += 1
    a = sum(ac)
    b = 0 
    for i in range(n):
        if ac[i]==1:
            b += wa[i]
    print(a, b)

if __name__ == '__main__':
    main()

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

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

for i, submit in enumerate(submits):
    p = int(submit[0])-1
    if acs[p]:
        continue
    if submit[1] == 'AC':
        acs[p] = True
    else:
        penalties[p] += 1

ac_num = sum(acs)
penalty_num = sum([p for i, p in enumerate(penalties) if acs[i]])

print("{} {}".format(ac_num, penalty_num))

Solution (Python):




N, M = map(int, input().split())
ac_list = [0] * N
wa_list = [0] * N
ac = int(0)
wa = int(0)
is_correct = [False] * N

if M == 0:
    print("0 0")
    exit()

for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if not is_correct[p]:
        if s == "AC":
            is_correct[p] = True
            ac_list[p] += 1
        else:
            wa_list[p] += 1

for i in range(N):
    if is_correct[i]:
        ac += ac_list[i]
        wa += wa_list[i]

print(ac, wa)

Solution (Python):

n, m = map(int, input().split())
bool_lst = [False] * n
ac_lst = [0] * n
wa_lst = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if bool_lst[p] == False:
        if s == 'AC':
            bool_lst[p] = True
            ac_lst[p] += 1
        else:
            wa_lst[p] += 1

ac_cnt = 0
wa_cnt = 0
for i in range(n):
    if bool_lst[i] == True:
        ac_cnt += ac_lst[i]
        wa_cnt += wa_lst[i]

print(ac_cnt, wa_cnt)

Solution (Python):
n, m = map(int, input().split())
bool_lst = [False] * n
ac_lst = [0] * n
wa_lst = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if bool_lst[p] == False:
        if s == 'AC':
            bool_lst[p] = True
            ac_lst[p] += 1
        else:
            wa_lst[p] += 1

ac_cnt = 0
wa_cnt = 0
for i in range(n):
    if bool_lst[i] == True:
        ac_cnt += ac_lst[i]
        wa_cnt += wa_lst[i]

print(ac_cnt, wa_cnt)

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

penalty = 0
a = [[False, 0] for i in range(N)]
count = 0

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if a[p][0] == False:
        if S == 'WA':
            a[p][1] += 1
        else:
            a[p][0] = True
            count += 1
    else:
        pass

print(count, sum([a[i][1] for i in range(N) if a[i][0] is True]))

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


AC_list = [0] * (n + 1)
WA = 0
WA_List = [0] * (n + 1)
 
for i in range(m):
    p,S = input().split()
    p = int(p)
 
    if S == "AC":
        
        if AC_list[p] == 0:
            AC += 1
            WA += WA_List[p]
            AC_list[p] = 1
        
    else:
        
        if AC_list[p] == 0:
            WA_List[p] += 1
        
 
print(AC,WA)

Solution (Python):
n, m = map(int, input().split())
p_li, s_li = [], []
for _ in range(m):
    p, s = input().split()
    p_li.append(int(p))
    s_li.append(s)

ac = [0] * n
wa = [0] * n
for i in range(m):
    p, s = p_li[i] - 1, s_li[i]
    if s == 'AC':
        ac[p] += 1
    elif ac[p] == 0:
        wa[p] += 1
    else:
        continue
n_ac, n_wa = 0, 0
for i in range(n):
    if ac[i] != 0:
        n_ac += 1
        n_wa += wa[i]
print('{} {}'.format(n_ac, n_wa))

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

for i in range(n):
    if cnt[i] == 0:
        wa[i] = 0
print(sum(cnt), sum(wa))

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

for m in range(M):
  p,s = input().split()
  p = int(p)
  
  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())
ans=[0]*n
pen=[0]*n
res_pen=0
for i in range(m):
  p,s=list(input().split())
  if ans[int(p)-1]!=1:
    if s=="AC":
      ans[int(p)-1]=1
      res_pen+=pen[int(p)-1]
    else:
      pen[int(p)-1]+=1
print(str(sum(ans))+" "+str(res_pen))

Solution (Python):
N,M=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(M):
    s=list(map(str,input().split()))
    if s[1]=="AC" and a[int(s[0])-1]==0:
        a[int(s[0])-1]+=1
    elif s[1]=="AC" and a[int(s[0])-1]==1:
        pass
    elif s[1]=="WA" and a[int(s[0])-1]==0:
        b[int(s[0])-1]+=1
for i in range(N):
    if b[i]>=1 and a[i]==0:
        b[i]=0
    
print(sum(a),sum(b))

Solution (Python):

import sys
n,m=map(int,raw_input().split())
fac=[0]*(n+1)
fwa=[0]*(n+1)
ac=0
wa=0
l=[]
for i in range(m):
 p,s=map(str,raw_input().split())
 p=int(p)
 if fac[p]==0:
  if s=='AC':
   fac[p]=1
   ac+=1
   wa+=fwa[p]
  else:
   fwa[p]+=1
print ac,wa

Solution (Python):
n,m = map(int,input().split())
ac_list = [0]*n
wa_list = [0]*n
pena = 0
for i in range(m):
    p,s = input().split()
    if s == 'AC':
        if ac_list[int(p)-1] == 0:
            ac_list[int(p)-1] =1
            pena += wa_list[int(p)-1]
        
    if s == 'WA':
        if ac_list[int(p)-1] == 0:
            wa_list[int(p)-1] += 1
            
print('{0} {1}'.format(sum(ac_list) , pena))

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

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

Solution (Python):
import collections

N, M = map(int, input().split())
dic = {i+1:[] for i in range(N)}
for i in range(M):
    x, y = input().split()
    dic[int(x)].append(y)
    
ac = 0
cnt = 0
for key in dic.keys():
    tmp = 0
    tmp_ac = 0
    for i in range(len(dic[key])):
        if(dic[key][i] == "AC"):
            ac += 1
            tmp_ac = 1
            break
        tmp += 1
    if(tmp_ac == 1):
        cnt += tmp
print(ac, cnt)

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
ac=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":
        num+=int_l[i]
        ac+=1
print(ac,num)

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


AC_list = [0] * N
penalty_list = [0] * N
ans_penalty_list = [0] * N

for i in range(M):
  if submit[i][1] == "WA":
    penalty_list[int(submit[i][0])-1] += 1
  else:
    if AC_list[int(submit[i][0])-1] == 0:
      AC_list[int(submit[i][0])-1] = 1
      ans_penalty_list[int(submit[i][0])-1] = penalty_list[int(submit[i][0])-1]

print(str(AC_list.count(1)), str(sum(ans_penalty_list)))

Solution (Python):

import sys


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    solved = [False]*N
    WAs = [0]*N
    WA = 0
    for i in range(M):
        if not solved[p[i]-1]:
            if S[i] == "WA":
                WAs[p[i]-1] += 1
            else:
                solved[p[i]-1] = True
    penalty = 0
    ACs = 0
    for i in range(N):
        if solved[i]:
            ACs += 1
            penalty += WAs[i]
    print(ACs, penalty)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    p = [int()] * (M)  
    S = [str()] * (M)  
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
p = [0] * M
S = [0] * M
for i in range(M):
    line = input().split()
    p[i] = int(line[0])
    S[i] = line[1]

AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]
for i in range(M):
    if AC[p[i] - 1]:
        pass
    else:
        if S[i] == "AC":
            AC[p[i] - 1] = True
        else:
            WA[p[i] - 1] += 1

n_AC = sum(AC)
n_WA = 0
for i in range(N):
    if AC[i]:
        n_WA += WA[i]

print(" ".join([str(n_AC), str(n_WA)]))

Solution (Python):
d = dict()
wa = ac = 0
N, M= map(int,input().split())
for i in range(M):
  a, b = input().split()
  if a not in d:
    d[a] = 0
  if d[a] >= 0 and b == "AC":
    ac += 1
    wa += d[a]
    d[a] = -1
  elif d[a] >= 0:
    d[a] += 1
print(ac,wa)

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

check = [True] * (n+1)
wa = [0] * (n+1)
wa_ans = 0
for i in range(m):
    if ps[i][1] == 'AC' and check[int(ps[i][0])]:
        check[int(ps[i][0])] = False
        wa_ans += wa[int(ps[i][0])]
    if ps[i][1] == 'WA':
        wa[int(ps[i][0])] += 1
ans = 0
for i in check:
    if not i:
        ans += 1

print(ans,wa_ans)

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

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

for el in d:
    if ac[int(el[0]) - 1] == 0:
        if el[1] == 'AC':
            ac[int(el[0]) - 1] += 1
        else:
            wa[int(el[0]) - 1] += 1
        
result = [0] * 2
for i in range(n):
    if ac[i] > 0:
        result[0] += 1
        result[1] += wa[i]
        
print(result[0], result[1])

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

check = [True] * (n+1)
wa = [0] * (n+1)
wa_ans = 0
for i in range(m):
    if ps[i][1] == 'AC' and check[int(ps[i][0])]:
        check[int(ps[i][0])] = False
        wa_ans += wa[int(ps[i][0])]
    if ps[i][1] == 'WA':
        wa[int(ps[i][0])] += 1
ans = 0
for i in check:
    if not i:
        ans += 1

print(ans,wa_ans)

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    complete = [False] * (N + 1)
    wans= [0] * (N + 1)
    ac = 0
    wc = 0
    for _ in range(M):
        p, ans = input().split()
        p = int(p)
        if complete[p]:
            continue
        if ans == 'AC':
            complete[p] = True
            ac += 1
            wc += wans[p]
        else:
            wans[p] += 1
    print(ac, wc)

resolve()

Solution (Python):
n,m = map(int,input().split())
aclist = [0]*(n+1)
walist = [0]*(n+1)
for i in range(m):
  p,s = input().split()
  if aclist[int(p)] == 0:
    if s == 'AC':
      aclist[int(p)] += 1
    else:
      walist[int(p)] += 1
for i in range(len(walist)):
  if aclist[i] == 0:
    walist[i] = 0
print(sum(aclist),sum(walist))