from collections import defaultdict N, M = map(int, input().split()) def merge(x, y): if x is None: return y return x U = 1 << 18 seg = [None] * (U * 2) for i in range(N + 1): seg[i + U] = i for i in reversed(range(1, U)): seg[i] = merge(seg[i * 2], seg[i * 2 + 1]) def erase(k): k += U seg[k] = None while k > 1: k >>= 1 seg[k] = merge(seg[k * 2], seg[k * 2 + 1]) def find(l): l += U r = 2*U - 1 resl = None resr = None while l <= r: if l % 2 == 1: resl = merge(resl, seg[l]) l += 1 if r % 2 == 0: resr = merge(seg[r], resr) r -= 1 l >>= 1 r >>= 1 return merge(resl, resr) ans = defaultdict(int) for _ in range(M): l, r, t = input().split() l = int(l) - 1 r = int(r) - 1 while True: l = find(l) if l > r: break ans[t] += 1 erase(l) print(ans['Y'], ans['K'], ans['C'])