import sys input = sys.stdin.readline N,M = map(int,input().split()) LRT = [input().split() for i in range(M)] #参照 #https://smijake3.hatenablog.com/entry/2018/11/03/100133 INF = 2**31-1 LV = N.bit_length() N0 = 2**LV data = [INF]*(2*N0) lazy = [None]*(2*N0) # 伝搬される区間のインデックス(1-indexed)を全て列挙するgenerator LV = (N-1).bit_length() N0 = 2**LV def gindex(l, r): L = l + N0; R = r + N0 lm = (L // (L & -L)) >> 1 rm = (R // (R & -R)) >> 1 while L < R: if R <= rm: yield R if L <= lm: yield L L >>= 1; R >>= 1 while L: yield L L >>= 1 # 1-indexedで単調増加のインデックスリストを渡す def propagates(*ids): for i in reversed(ids): v = lazy[i-1] if v is None: continue lazy[2*i-1] = data[2*i-1] = lazy[2*i] = data[2*i] = v lazy[i-1] = None def update(l, r, x): *ids, = gindex(l, r) # 1. トップダウンにlazyの値を伝搬 propagates(*ids) # 2. 区間[l, r)のdata, lazyの値を更新 L = N0 + l; R = N0 + r while L < R: if R & 1: R -= 1 lazy[R-1] = data[R-1] = x if L & 1: lazy[L-1] = data[L-1] = x L += 1 L >>= 1; R >>= 1 # 3. 伝搬させた区間について、ボトムアップにdataの値を伝搬する for i in ids: data[i-1] = min(data[2*i-1], data[2*i]) def query(l, r): # 1. トップダウンにlazyの値を伝搬 propagates(*gindex(l, r)) L = N0 + l; R = N0 + r # 2. 区間[l, r)の最小値を求める s = INF while L < R: if R & 1: R -= 1 s = min(s, data[R-1]) if L & 1: s = min(s, data[L-1]) L += 1 L >>= 1; R >>= 1 return s for i,(l,r,t) in reversed(list(enumerate(LRT))): l,r = int(l),int(r) update(l,r+1,i) y = k = c = 0 for i in range(1,N+1): j = query(i,i+1) if j >= M: continue t = LRT[j][2] if t=='Y': y += 1 elif t=='K': k += 1 else: c += 1 print(y,k,c)