import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') #sys.set_int_max_str_digits(10**9) class Dual_Segment_Tree: def __init__(self,N,f_act,e_act,operate,lst): self.N=N self.f_act=f_act self.e_act=e_act self.operate=operate self.lst=[None]*self.N for i,x in enumerate(lst): self.lst[i]=x self.segment_tree_act=[self.e_act]*(self.N+self.N) def __getitem__(self,i): if type(i) is int: if -self.N<=i<0: i+=self.N*2 elif 0<=i>h) def Operate_Range(self,a,L=None,R=None): if L==None: L=self.N else: L+=self.N if R==None: R=self.N*2 else: R+=self.N L0=L//(L&-L) R0=R//(R&-R)-1 self.Propagate_Above(L0) self.Propagate_Above(R0) while L>=1 R>>=1 def Update(self): for i in range(1,self.N): self.Propagate_At(i) self.segment_tree_act[i]=self.e_act def __str__(self): import copy segment_tree_act=copy.deepcopy(self.segment_tree_act) for i in range(1,self.N): segment_tree_act[i<<1]=self.f_act(segment_tree_act[i<<1],segment_tree_act[i]) segment_tree_act[i<<1|1]=self.f_act(segment_tree_act[i<<1|1],segment_tree_act[i]) segment_tree_act[i]=self.e_act segment_tree_act[i]=self.e_act return "["+", ".join(map(str,[self.operate(x,a) for x,a in zip(self.lst,segment_tree_act[self.N:])]))+"]" N,M=map(int,readline().split()) LRT=[] for m in range(M): l,r,t=readline().split() l=int(l)-1 r=int(r) LRT.append((l,r,t)) def f_act(a,b): if b==None: return a return b e_act=None def operate(x,a): if a==None: return x return a DST=Dual_Segment_Tree(N,f_act,e_act,operate,[None]*N) for l,r,t in LRT[::-1]: DST.Operate_Range(t,l,r) C=defaultdict(int) for i in range(N): C[DST[i]]+=1 ans_lst=[C[s] for s in "YKC"] print(*ans_lst)