import sys input = sys.stdin.readline class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i # i+1番目からR番目まで足すとt以上となるような最小のRを返す def bisect_plus(self, i, t): L = i R = self.size R_prev = R sum_i = self.sum(i) while True: range_sum = self.sum(R) - sum_i if range_sum < t: if R == self.size: return self.size + 1 L, R = R, R_prev else: R_prev = R R = (L + R + 1) // 2 if R == R_prev: return R # L番目からi-1番目まで足すとt以上となるような最小のLを返す def bisect_minus(self, i, t): L = 1 R = i L_prev = L sum_i = self.sum(i - 1) while True: range_sum = sum_i - self.sum(L - 1) if range_sum < t: if L == 1: return 0 L, R = L_prev, L else: L_prev = L L = (L + R) // 2 if L == L_prev: return L def main(): N, M = map(int, input().split()) q = [] qy = [0] * (M+1) ans = [0] * 3 bit = Bit(N) for i in range(1, M+1): s, t, y = input().split() s = int(s) t = int(t) if y == 'K': qy[i] = 1 elif y == 'C': qy[i] = 2 q.append((s, 1, i)) if t+1 <= N: q.append((t+1, -1, i)) for i in range(1, N+1): q.append((i, 0, 0)) q.sort(key=lambda x: x[0]) for i, flg, j in q: if flg == 1: bit.add(j, 1) elif flg == -1: bit.add(j, -1) elif flg == 0: k = bit.bisect_plus(0, 1) if k == N+1: continue ans[qy[k]] += 1 print(*ans) if __name__ == '__main__': main()