import heapq class Heapq: def __init__(self, lst = [], reverse = False): if reverse: self.pm = -1 self.hq = [-l for l in lst] else: self.pm = 1 self.hq = lst.copy() heapq.heapify(self.hq) self.tot = sum(lst) self.rm = [] self.length = len(lst) def push(self, x): self.length += 1 heapq.heappush(self.hq, x * self.pm) self.tot += x def pop(self): self.length -= 1 ret = heapq.heappop(self.hq) self.tot -= self.pm * ret self.delete() return self.pm * ret def top(self): return self.pm * self.hq[0] def remove(self, x): # 存在しないものを消そうとするとバグる self.length -= 1 self.tot -= x heapq.heappush(self.rm, self.pm * x) self.delete() def delete(self): while self.rm and self.rm[0] == self.hq[0]: heapq.heappop(self.rm) heapq.heappop(self.hq) n, m = map(int, input().split()) add = [[] for _ in range(n)] rem = [[] for _ in range(n)] T = [""] * m for i in range(m): l, r, t = input().split() T[i] = t add[int(l) - 1].append(i) rem[int(r) - 1].append(i) ans = {"Y":0, "K":0, "C":0} hq = Heapq() for i in range(n): for j in add[i]: hq.push(j) if hq.length > 0: t = T[hq.top()] ans[t] += 1 for j in rem[i]: hq.remove(j) print(ans["Y"], ans["K"], ans["C"])