from collections import defaultdict import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] class SegmentTree: def __init__(self, aa): width = 1 << ((len(aa) - 1).bit_length()) tree = [-1] * (width * 2 - 1) lazy = [-1] * (width * 2 - 1) tree[width - 1:] = aa self.width = width self.tree = tree self.lazy = lazy def _prop(self, u): if self.lazy[u] == -1: return value = self.tree[u] = self.lazy[u] self.lazy[u] = -1 if u < self.width - 1: self.lazy[u * 2 + 1] = self.lazy[u * 2 + 2] = value def update(self, l, r, a, u=0, uL=0, uR=-1): if uR == -1: uR = self.width self._prop(u) if r <= uL or uR <= l: return elif l <= uL and uR <= r: self.lazy[u] = a return uM = (uL + uR) // 2 self.update(l, r, a, u * 2 + 1, uL, uM) self.update(l, r, a, u * 2 + 2, uM, uR) def get_elements(self): for u in range(self.width - 1): self._prop(u) for u in range(self.width - 1, self.width * 2 - 1): if self.lazy[u] == -1: continue self.tree[u] = self.lazy[u] return self.tree[self.width - 1:] def main(): n, m = MI() lrt = [input().split() for _ in range(m)] aa = [-1] * n st = SegmentTree(aa) for l, r, t in lrt[::-1]: l, r = int1(l), int(r) if t == "Y": mark = 1 elif t == "K": mark = 2 else: mark = 3 st.update(l, r, mark) aa = st.get_elements() cnt = defaultdict(int) for a in aa: cnt[a] += 1 print(cnt[1], cnt[2], cnt[3]) main()