import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) class UF_tree: def __init__(self, n): self.root = [-1] * n self.rank = [0] * n def find(self, x): stack = [] while self.root[x] > 0: stack.append(x) x = self.root[x] for i in stack: self.root[i] = x return x def isSame(self, x, y): return self.find(x) == self.find(y) def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return False if x > y: x, y = y, x self.root[y] += self.root[x] self.root[x] = y return True def size(self, x): return -self.root[self.find(x)] N, M = map(int, input().split()) yck = [0] * N uf = UF_tree(N+1) ans = [0, 0, 0] for _ in range(M): l, r, t = input().rstrip().split() L = int(l) - 1 R = int(r) i = "YKC".find(t) while L < R: if not yck[L]: ans[i] += 1 yck[L] = 1 uf.unite(L, L+1) L = uf.find(L) print(*ans)