import sys input = sys.stdin.readline INF = 2**31 - 1 class LazySegmentTree: def __init__(self, n): LV = (n-1).bit_length() self.N0 = 2 ** LV self.data = [INF] * (2*self.N0) self.lazy = [None] * (2*self.N0) def gindex(self, l, r): L = l + self.N0; R = r + self.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 def propagates(self, *ids): for i in reversed(ids): v = self.lazy[i-1] if v is None: continue self.lazy[2*i-1] = self.data[2*i-1] = self.lazy[2*i] = self.data[2*i] = v self.lazy[i-1] = None def update(self, l, r, x): #RUQ change a[l:r) to x *ids, = self.gindex(l, r) self.propagates(*ids) L = self.N0 + l; R = self.N0 + r while L < R: if R & 1: R -= 1 self.lazy[R-1] = self.data[R-1] = x if L & 1: self.lazy[L-1] = self.data[L-1] = x L += 1 L >>= 1; R >>= 1 for i in ids: self.data[i-1] = min(self.data[2*i-1], self.data[2*i]) def query(self, l, r): #RMQ min(a[l:r)) self.propagates(*self.gindex(l, r)) L = self.N0 + l; R = self.N0 + r s = INF while L < R: if R & 1: R -= 1 s = min(s, self.data[R-1]) if L & 1: s = min(s, self.data[L-1]) L += 1 L >>= 1; R >>= 1 return s N, M = map(int, input().split()) LRT = [] for _ in range(M): Li, Ri, Ti = input().split() Li = int(Li) Ri = int(Ri) if Ti=='Y': LRT.append((Li, Ri, 1)) elif Ti=='K': LRT.append((Li, Ri, 2)) elif Ti=='C': LRT.append((Li, Ri, 3)) lst = LazySegmentTree(N) for i in range(M-1, -1, -1): Li, Ri, Ti = LRT[i] lst.update(Li-1, Ri, Ti) Y, K, C = 0, 0, 0 for i in range(N): v = lst.query(i, i+1) if v==1: Y += 1 elif v==2: K += 1 elif v==3: C += 1 print(Y, K, C)