import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 md = 998244353 # md = 10**9+7 n, m = LI() w = 1 << (n-1).bit_length() tree = [inf]*w*2 tt = [] for i in range(m): l, r, t = SI().split() l, r = int(l)-1, int(r) t = "YKC".index(t) tt.append(t) stack = [(1, 0, w)] while stack: u, ul, ur = stack.pop() if ur <= l or r <= ul: continue if tree[u] != inf: continue if l <= ul and ur <= r: tree[u] = i else: um = (ul+ur)//2 stack.append((u*2, ul, um)) stack.append((u*2+1, um, ur)) # print(i,l,r,stack,tree) for u in range(2, w+n): tree[u] = min(tree[u], tree[u//2]) cnt = [0]*3 for k in range(n): i = tree[k+w] if i != inf: cnt[tt[i]] += 1 print(*cnt)