#include using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() const int mod=998244353,MAX=200005; const ll INF=1LL<<60; template struct LazySegmentTree{ using F=function; using G=function; using H=function; int n; vector dat; vector lazy; F f; G g; H h; T ti; E ei; LazySegmentTree(int n_,F f,G g,H h,T ti,E ei) :f(f),g(g),h(h),ti(ti),ei(ei){ n=1; while(n &v,F f,G g,H h,T ti,E ei) :f(f),g(g),h(h),ti(ti),ei(ei){ n=1; while(n=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]); lazy.assign(2*n-1,ei); } inline void eval(int k,int l,int r){ if(lazy[k]==ei) return; dat[k]=g(dat[k],lazy[k]); if(r-l>1){ lazy[k*2+1]=h(lazy[k*2+1],lazy[k]); lazy[k*2+2]=h(lazy[k*2+2],lazy[k]); } lazy[k]=ei; } void update_(int a,int b,E x,int k,int l,int r){ eval(k,l,r); if(r<=a||b<=l) return; if(a<=l&&r<=b){ lazy[k]=h(lazy[k],x); eval(k,l,r); } else{ update_(a,b,x,2*k+1,l,(l+r)/2); update_(a,b,x,2*k+2,(l+r)/2,r); dat[k]=f(dat[2*k+1],dat[2*k+2]); } } void update(int a,int b,E x){ return update_(a,b,x,0,0,n); } T query_(int a,int b,int k,int l,int r){ eval(k,l,r); if(r<=a||b<=l) return ti; if(a<=l&&r<=b) return dat[k]; T vl=query_(a,b,2*k+1,l,(l+r)/2); T vr=query_(a,b,2*k+2,(l+r)/2,r); return f(vl,vr); } T query(int a,int b){ return query_(a,b,0,0,n); } }; //区間和はTをpairにするa int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int N,M;cin>>N>>M; auto f=[&](int a,int b){return max(a,b);}; auto g=[&](int a,int b){ if(a==0) return b; else return a; }; auto h=[&](int a,int b){ if(a==0) return b; else return a; }; LazySegmentTree seg(N, f, g, h, 0, 0); for(int i=0;i>a>>b>>c; if(c=='Y') seg.update(a-1,b,1); if(c=='K') seg.update(a-1,b,2); if(c=='C') seg.update(a-1,b,3); } vector ans(4); for(int i=0;i