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

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, P, S):
    ac = set()
    wa = Counter()
    for i in range(M):
        if S[i] == 'AC':
            ac.add(P[i])
        elif P[i] not in ac:
            wa[P[i]] += 1
    return '%d %d' % (len(ac), sum([wa[i] for i in range(1, N+1) if i in ac]))


def main():
    N, M = read_int_n()
    P, S = [], []
    for _ in range(M):
        p, s = read_str_n()
        p = int(p)
        P.append(p)
        S.append(s)
    print(slv(N, M, P, S))


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

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

_ac = np.array([0 for i in range(n)])
_wa = np.array([0 for i in range(n)])

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

ac = _ac
wa = _ac * _wa

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

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
def run_length_encode(s):
    count = 1
    code = []
    target = s[0]
    for i in range(1, len(s)):
        if target == s[i]: count += 1
        else:
            code.append((target, count))
            target = s[i]
            count = 1
    code.append((target, count))
    return code

N,M = imn()
PS = [input().split() for _ in range(M)]
AC = set()
WA = {}
for i in range(M):
    if PS[i][1] == 'AC':
        AC.add(PS[i][0])
    else:
        if PS[i][0] not in AC:
            if PS[i][0] not in WA:
                WA[PS[i][0]] = 1
            else:
                WA[PS[i][0]] += 1
WA_cnt = 0
for k, v in WA.items():
    if k in AC:
        WA_cnt += v

print(len(AC), WA_cnt, sep=' ')

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
li=[[0,0] for i in range(n+1)] 
wa=0
ans=0

for i in range(m):
    if li[int(ps[i][0])][0]==0:
        if ps[i][1]=="AC":
            li[int(ps[i][0])][0]+=1
        else:
            li[int(ps[i][0])][1]+=1
    else:
        continue
for i in range(n+1):
    if li[i][0]==0:
        continue
    else:
        ans+=1
        wa+=li[i][1]
print(ans)
print(wa)

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

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

freq = {}
for i in range(m):
  p, s = input().split()
  if not p in freq:
    freq[p] = [0, 0]
  if freq[p][0] == 0:
    freq[p][['AC', 'WA'].index(s)] += 1

print(sum(c for c, w in freq.values() if c > 0), sum(w for c, w in freq.values() if c > 0))

Solution (Python):
n,m = map(int, input().split())
a = [0]*(n+1)
ans1 = 0
ans2 = 0
for i in range(m):
  p,s = map(str, input().split())
  p = int(p)
  if s == "WA":
    if a[p] != -1:
      a[p] += 1
  else:
    if a[p] != -1:
      ans1 += 1
      ans2 += a[p]
      a[p] = -1
print(ans1,ans2)

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

lst2 = [0]*n 
lst3 = [0]*n 

for i,j in lst1:
    i = int(i)-1
    if lst2[i] == 0:
        if j == "WA":
            lst3[i] += 1
        else:
            lst2[i] = 1
        
        
pena = 0
for i in range(n):
    if lst2[i]  == 1:
        pena += lst3[i]
print(sum(lst2),pena)

Solution (Python):
N, M = [int(x) for x in input().split()]
ans = [0] * N
pen = [0] * N
for _ in range(M):
    ps, S = [x for x in input().split()]
    p = int(ps)-1
    if S == 'WA':
        if ans[p] == 0:
            pen[p] += 1
    else:
        ans[p] = 1
ans1 = 0
ans2 = 0
for a, p in zip(ans, pen):
    ans1 += a
    ans2 += (a*p)
print(ans1, ans2)

Solution (Python):
N, K= [int(x) for x in input().split()]
t = [[] for i in range(N)]
for i in range(K):
  q,ans = input().split()
  t[int(q)-1].append(ans)

wa = 0
ac = 0
for i in t:
  w_tmp = 0
  for j in i:
    if j == "WA":
      w_tmp += 1
    elif j== "AC":
      ac += 1
      wa += w_tmp
      break
print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
submits = [tuple(input().split()) for _ in range(M)]
accepted = {i: 0 for i in range(1, N+1)}
ACs = 0
WAs = 0
for p, S in submits:
    p = int(p)
    if accepted[p] < 0: continue
    if S == 'AC':
        ACs += 1
        WAs += accepted[p]
        accepted[p] = -1
    else:
        accepted[p] += 1
print(ACs, WAs)

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

success = 0
fail = 0
check = {}
for i in range(m):
    p, s = input().split()
    if s == "WA":
        if p in check:
            if check[p] < 0:
                pass
            else:
                check[p] += 1
        else:
            check[p] = 1
    else:
        if p in check:
            if check[p] < 0:
                continue
            fail += check[p]
        check[p] = -1
        success += 1
print(success, fail)

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


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

    ac_list = [False] * N
    wa_counts = [0] * N
    total_wa = 0

    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if ac_list[p]:
            continue
        if s == "AC":
            ac_list[p] = True
            total_wa += wa_counts[p]
            continue
        else:
            wa_counts[p] += 1

    print(sum(ac_list), total_wa)


if __name__ == '__main__':
    main()

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

for i in range(m):
    a,b = input().split()

    if b == "AC":
        na[int(a)-1] = 1
    elif b == "WA":
        if na[int(a)-1] == 0:
            nw[int(a)-1] += 1
count = 0
print(sum(na),end="")
for i in range(n):
    if na[i] == 1:
        count += nw[i]
print(" {}".format(count))

Solution (Python):
N, M = map(int,input().split())
p =[]
S =[]
for i in range(M):
    p1, S1 = map(str,input().split())
    p.append(int(p1))
    S.append(S1)
    
wa = [0] * (N+1)
ac = [0] * (N+1)
answ = 0
for i in range(M):
    if S[i] == "AC" and ac[p[i]] == 0:
        answ += wa[p[i]]
        ac[p[i]] = 1
    else:
        wa[p[i]] += 1

ans = [str(sum(ac)), str(answ)]

print(" ".join(ans))

Solution (Python):
n, nSubms = map(int, input().split())
waCnt = [0] * (n + 1)
ac = [0] * (n + 1)
for _ in range(nSubms):
    id, res = input().split()
    id = int(id)
    if res == 'WA':
        if not ac[id]:
            waCnt[id] += 1
    elif res == 'AC':
        if not ac[id]:
            ac[id] = 1
    else:
        raise Exception
for i in range(n + 1):
    if waCnt[i] and not ac[i]:
        waCnt[i] = 0
print('%d %d' % (sum(ac), sum(waCnt)))

Solution (Python):
n, m = map(int, input().split())
arr = [0] * (n + 1)
arr2 = [0] * (n + 1)
corr = 0
pen = 0
for i in range(m):
    p, s = map(str, input().split())
    if s == 'AC':
        arr[int(p)] = 1
    else:
        if arr[int(p)] == 0:
            arr2[int(p)] -= -1
for i in range(n + 1):
    if arr[i] == 1:
        corr -= -1
        pen += arr2[i]
print(corr, pen)

Solution (Python):
import numpy as np
n, m = map(int,input().split())
questions = [0 for i in range(n)]
clear = [0 for i in range(n)]
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA':
        if clear[p-1] == 0:
            questions[p-1] += 1
    else:
        clear[p-1] = 1
questions = np.array(questions)
print(sum(clear), questions[np.where(np.array(clear) == 1)[0]].sum())

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

ans = {(x + 1): [0, 0] for x in range(N)}

for i in range(M):
    a = p[i]
    b = S[i]
    if b == 'AC':
        ans[a][0] += 1
    else:
        if ans[a][0] == 0:
            ans[a][1] += 1

ac = 0
wa = 0
for i in range(1, N + 1):
    if ans[i][0] > 0:
        ac += 1
        wa += ans[i][1]

print(ac, wa)

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

ans = 0
clear = 0

chk = [0]*(n+1)

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

print(str(clear)+" "+str(ans))

Solution (Python):
n, m = map(int, input().split())
p = []
s = []

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



acSet = set()
acCnt = 0
waCnt = 0
waTempMap = [0]*(n+1)

for i in range(m):
    prob = p[i]
    res = s[i]

    if res == 'AC':
       if prob not in acSet:
           acSet.add(prob)
           acCnt += 1
           waCnt += waTempMap[prob]
    else:
        waTempMap[prob] += 1
        

print(acCnt, waCnt)

Solution (Python):
N, M = map(int, input().split())
l = [0 for i in range(N)]
cnt = [0 for i in range(N)]
for i in range(M):
    p,s = map(str, input().split())
    p = int(p)-1
    if s == "AC":
        l[p] = 1
    elif s == "WA":
        if l[p] == 0:
            cnt[p] += 1

mis = 0
for i in range(N):
    if l[i] == 1:
        mis += cnt[i]
print(sum(l), mis)

Solution (Python):

import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline

n, m = [int(item) for item in input().split()]
ok = [False] * n
cnt = [0] * n
submit = []
was = 0
ans = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if not ok[p] and s == "WA":
        cnt[p] += 1
    elif not ok[p] and s == "AC":
        ans += 1
        was += cnt[p]
        ok[p] = True 


print(ans, was)

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

miss=0

li=[0 for j in range(n)]
li1=[0 for j in range(n)]

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

    
print(sum(li),miss)

Solution (Python):
n,m=[int(i) for i in input().split()]
arr=[0 for i in range(n+1)]
wa=[0 for i in range(n+1)]
ac=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if arr[p]==1:
        pass
    else:
        if s=='WA':
            wa[p]+=1
        else:
            ac+=1
            arr[p]=1
pen=0
for i in range(n+1):
    if arr[i]==1:
        pen+=wa[i]
print(ac,pen)

Solution (Python):
N, M = map(int, input().split())
ans = set()
WA = [0] * N
flag = [0] * N
for i in range(M):
    q, result = input().split()
    if result == "AC":
        ans.add(int(q))
        flag[int(q)-1] = 1
    else:
        if not int(q) in ans:
            WA[int(q)-1] += 1

WA_tot = 0        
for i in range(N):
    if flag[i] == 1:
        WA_tot += WA[i]
print(len(ans), WA_tot)

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

dwa = {}
dac = {}
ansac = 0
answa = 0

for m in range(m):
  p, s = map(str, input().split())
  p = int(p)
  if s == 'WA':
    if p in dwa:
      dwa[p] += 1
    else:
      dwa[p] = 1
  if s == 'AC' and p not in dac:
    ansac += 1
    dac[p] = 1
    if p in dwa:
      answa += dwa[p]
    
print(ansac, answa)

Solution (Python):
N,M=map(int,input().split())
p=[0]*M
S=["a"]*M

x=[0]*N
y=[0]*N
for i in range(M):
  p[i],S[i]=input().split()
  k=int(p[i])-1
  if x[k]==0:
    if S[i]=="WA":
      y[k]+=1
    else:
      x[k]=1
z=sum(x)
w=0
for i in range(N):
  if x[i]==1:
    w+=y[i]
print(z,w)

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

problem = [False] * n
count_wa = [0] * n


for _ in range(m):
    num, res = input().split()
    num = int(num) - 1

    if res == 'AC':
        problem[num] = True

    else:
        if problem[num] == False:
            count_wa[num] += 1
        else:
            continue

a = sum(problem)
b = 0

for i in range(n):
    if problem[i] == True:
        b += count_wa[i]

print(a, b)

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

def main():
    ac = 0
    wa = 0
    dic = {}
    cleared = {}
    for p,s in PS:
        if s == "AC" and p not in cleared:
            cleared[p] = True
            if p in dic:
                wa += dic[p]
            ac += 1
        else:
            if p in dic:
                dic[p] += 1
            else:
                dic[p] = 1
    print(ac,wa)
    return 


if __name__ == "__main__":
    main()

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

problems = [0] * N
ans = [0, 0]

for _ in range(M):
    p, S = input().split()
    i = int(p) - 1
    if problems[i] == -1:
        continue
    if S == "WA":
        problems[i] += 1
    else:
        ans[0] += 1
        ans[1] += problems[i]
        problems[i] = -1

print(" ".join(map(str, ans)))

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import itertools as it

N, M = two_int()

AC_dicts={}
WA_dicts={}

for i in range(M):
    p, s = input().split()
    
    if p in AC_dicts:
        continue
    
    if s =="AC":
        AC_dicts[p] = 1
        continue
    
    if p not in WA_dicts:
        WA_dicts[p] = 1
    else:
        WA_dicts[p] += 1

wa_sums = 0
for k in AC_dicts.keys():
    if k in WA_dicts:
        wa_sums += WA_dicts[k]



ac_sums = 0
for k,v in AC_dicts.items():
    ac_sums += v


print(str(ac_sums) +" " + str(wa_sums) )

Solution (Python):
N, M = map(int, input().split())
D = {}
for i in range(M):
  p, S = map(str, input().split())
  p = p
  if p in D:
    if S == "AC":
      D[p][1] = 1
    if D[p][1] == 0:
      D[p][0] += 1
  else:
    if S == "WA":
      D[p] = [1, 0]
    else:
      D[p] = [0, 1]
SUM41 = 0
SUM42 = 0
for i in D:
  if D[i][1] == 1:
    SUM41 += D[i][0]
    SUM42 += 1
print(SUM42, SUM41)

Solution (Python):
n, m = map(int, input().split())
p = [False for _ in range(n + 1)]
ze = [0 for _ in range(n + 1)]
ac = 0
wa = 0

for i in range(m):
    string = input().split()
    prob = int(string[0])
    res = string[1]
    if p[prob]:
        pass
    elif res == "AC":
        p[prob] = True
        wa += ze[prob]
        ac += 1
    else:
        ze[prob] += 1

print(ac, wa)

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

subs = defaultdict(list)
for i in range(M):
    p, s = map(str, input().split())
    p = int(p)
    subs[p].append(s)

ac = 0
pena = 0
for k, v in subs.items():
    wa = 0
    for a in v:
        if a == 'AC':
            ac += 1
            pena += wa
            break
        wa += 1

print(ac, pena)

Solution (Python):
def main(sample_file = ''):

    """ convenient functions
    
    
    
    
    
    """

    """convenient decorator
    
    
        
        
        
        
        
        
        
        
        
        
    """
    
    
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product 
    
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  
        b, e = 2, 0  
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict 
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
    from copy import deepcopy, copy 
    import operator
    from operator import itemgetter 
    
    
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd 
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)
    def make_divisors(n, reversed=False):
        """create list of divisors
        
        Args:
            number (int): number from which list of divisors is created
            reversed (bool, optional): ascending order if False. Defaults to False.
        
        Returns:
            list: list of divisors
        """
        divisors = set()
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.add(i)
                divisors.add(n//i)
        return sorted(list(divisors),reverse=reversed)
    
    
    
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) 
    def modinv(a, p = MOD):
        
        
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        
        
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    class UnionFindTree:
        """union find tree class
        TODO: fix this description...
        how to use (example):
        >>  uf = UnionFindTree(N) 
        >>  if uf.find_root(a) == uf.find_root(b):
        >>      do something
        >>  else:
        >>      do something
        >>      uf.unite(a, b)
        """
        def __init__(self, N):
            self.root = [-1] * (N+1)
            self.rank   = [0]  * (N+1)
            self.connected_num = [1] * (N+1)
    
        def find_root(self,x):
            root = self.root
            while root[x] != -1:
                x = root[x]
            return x
    
        def unite(self,x,y):
            root = self.root
            rank = self.rank
            connected_num = self.connected_num
            find_root = self.find_root
    
            rx = find_root(x)
            ry = find_root(y)
            if rx != ry:
                if rank[rx] < rank[ry]:
                    root[rx] = ry
                    rx,ry = ry,rx
                else:
                    if rank[rx] == rank[ry]:
                        rank[rx] += 1
                    root[ry] = rx       
                connected_num[rx] += connected_num[ry]

    
    
    
    
    

    def BellmanFord(N, M, ABC, vertex_start, vertex_end, value_if_inf = -1, find_shortest = False):
        """to calculate furthest or shortest length between vertex_start and vertex_end using BellmanFord algorithm
        
        Args:
            N (int): number of vertices
            M (int): number of edges
            ABC (list): [(ai, bi, ci) for _ in range(N)] where i-th edge is directed from vertex ai to vertex bi and the length is ci 
            vertex_start (int): start vertex. usually use 0.
            vertex_end (int): end vertex. usually use N-1.
            value_if_inf (int or string as you like, optional): value you want when the furthest (or shortest) distance is infinite (or -infinite). Defaults to -1.
            find_shortest (bool, optional): choose False to find furthest path. Defaults to False.
        
        Returns:
            int or string: normally int (but can be str if you set value_if_inf to str)
            
        Example:
                N, M, P = R()
                ABC = [R() for _ in range(M)]
                ABC = [(a-1, b-1, c-P) for a, b, c in ABC]
                print(BellmanFord(N, M, ABC, 0, N-1, value_if_inf = 'inf'))

        """

        def make_reachable_list(N, M, ABC, vertex_start, vertex_end):
            reachable_to_direct = defaultdict(list)
            reachable_from_direct = defaultdict(list)
            reachable_from_start = [False] * N
            reachable_to_end = [False] * N
            reachable_from_start[vertex_start] = True
            reachable_to_end[vertex_end] = True
            reachable_from_both_sides = [False] * N
            dfs_from_start = []
            dfs_to_end = []
            for a, b, c in ABC:
                reachable_to_direct[a].append(b)
                reachable_from_direct[b].append(a)
                if a == vertex_start:
                    dfs_from_start.append(b)
                    reachable_from_start[b] = True
                if b == vertex_end:
                    dfs_to_end.append(a)
                    reachable_to_end[a] = True
            while dfs_from_start:
                v = dfs_from_start.pop()
                for i in reachable_to_direct[v]:
                    if not reachable_from_start[i]:
                        reachable_from_start[i] = True
                        dfs_from_start.append(i)
            while dfs_to_end:
                v = dfs_to_end.pop()
                for i in reachable_from_direct[v]:
                    if not reachable_to_end[i]:
                        reachable_to_end[i] = True
                        dfs_to_end.append(i)
            for i in range(N):
                reachable_from_both_sides[i] = reachable_from_start[i] and reachable_to_end[i]
            return reachable_from_both_sides
        
        reachable_from_both_sides = make_reachable_list(N, M, ABC, vertex_start, vertex_end)
        
        if find_shortest:
            dist = [INF for i in range(N)]
        else:
            dist = [-INF for i in range(N)]
        
        dist[vertex_start] = 0
        for i in range(N):
            updated = False
            for a, b, c in ABC:
                if not reachable_from_both_sides[a]:
                    continue
                elif find_shortest:
                    update_condition = dist[a] + c < dist[b]
                else:
                    update_condition = dist[a] + c > dist[b]
                if dist[a] != INF and update_condition:
                    dist[b] = dist[a] + c
                    updated = True
                    if i == N-1:
                        return value_if_inf
            if not updated:
                break
        return dist[vertex_end]

    """ initialize variables and set inputs
    
        
        
            
            
    
        
        
        
        
        
        
        
    
        
        
        
        
    
        
        
    """

    
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    r_float = lambda: float(r())
    R = lambda: list(map(int, r().split()))
    R_str = lambda: r().split()
    R_map = lambda: map(int, r().split())
    R_float = lambda: list(map(float, r().split()))
    R_tuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    
    
    
    
    
    
    
    """

    
    if sample_file:
        sys.stdin = open(sample_file)
        
    
    

    N, M = R()
    PS = [R_str() for _ in range(M)]
    l = [0] * N
    cnt = [0] * N
    cnt_a = 0
    ans = 0
    for i, (pp, s) in enumerate(PS):
        p = int(pp) - 1
        if l[p] == 1:
            continue
        else:
            if s == 'WA':
                cnt[p] += 1
            else:
                l[p] = 1
                cnt_a += cnt[p]
                ans += 1
    print(ans, cnt_a)
    
    
    
    

    """memo: how to use defaultdict of list
    
    Dic = defaultdict(list)
    
    Dic[x].append(y)
    
    for k, v in Dic.items():
    """
    
    """memo: how to solve binary problems
    
    >>> a = 5
    >>> bin_str_a = format(a, '
    >>> print(bin_str_a)
    0b0101 
    """
    
    """memo: how to solve the problem
    creating simple test/answer
    greed
    simple dp
    graph
    """

if __name__ == '__main__':
    main()