import sys input = sys.stdin.readline class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] self.nex = [i + 1 for i in range(n)] def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, x, y): x = self.find(x) y = self.find(y) v = max(self.nex[x], self.nex[y]) if x != y: if self.rank[x] < self.rank[y]: x, y = y, x if self.rank[x] == self.rank[y]: self.rank[x] += 1 self.par[y] = x self.size[x] += self.size[y] self.nex[x] = self.nex[y] = v def is_same(self, x, y): return self.find(x) == self.find(y) def get_size(self, x): x = self.find(x) return self.size[x] N, M = map(int, input().split()) ans = [-1] * N U = UnionFind(N + 1) for i in range(M): L, R, T = input().split() L, R = int(L) - 1, int(R) - 1 now = L while now <= R: if ans[now] == -1: ans[now] = T temp = U.nex[now] U.union(now, now + 1) now = temp print(ans.count("Y"), ans.count("K"), ans.count("C"))