#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x V; ll N; int Q; int VL; int X[161010]; ll L[161010],R[161010]; template class SegTree_Lazy { public: vector val,tot,clean; SegTree_Lazy(){val.resize(NV*2); tot.resize(NV*2);clean.resize(NV*2);}; ll getval(int x,int y,int l=0,int r=NV,int k=1) { if(r<=x || y<=l) return 0; if(clean[k]) return 0; if(x<=l && r<=y) return tot[k]; x=max(x,l); y=min(y,r); return val[k]*(V[min(y,VL)]-V[min(x,VL)]) + getval(x,y,l,(l+r)/2,k*2) + getval(x,y,(l+r)/2,r,k*2+1); } void clear(int x,int y,int l=0,int r=NV,int k=1) { if(r<=x || y<=l) return; if(clean[k]) return; if(x<=l && r<=y) { clean[k]=1; val[k]=tot[k]=0; } else { if(clean[2*k]) { clean[2*k]=val[2*k]=tot[2*k]=0; if(2*k<=NV) clean[2*k*2]=clean[2*k*2+1]=0; } if(clean[2*k+1]) { clean[2*k+1]=val[2*k+1]=tot[2*k+1]=0; if(2*k+1<=NV) clean[2*(k+1)*2]=clean[2*(k+1)*2+1]=0; } val[2*k]+=val[k]; tot[2*k]+=val[k]*(V[min((l+r)/2,VL)]-V[min(l,VL)]); val[2*k+1]+=val[k]; tot[2*k+1]+=val[k]*(V[min(r,VL)]-V[min((l+r)/2,VL)]); val[k]=0; clear(x,y,l,(l+r)/2,k*2); clear(x,y,(l+r)/2,r,k*2+1); tot[k]=tot[2*k]+tot[2*k+1]; } } void inc(int x,int y,int l=0,int r=NV,int k=1) { if(r<=x || y<=l) return; if(clean[k]) { if(k<=NV) { clean[2*k]=1; clean[2*k+1]=1; } clean[k]=0; val[k]=tot[k]=0; } if(x<=l && r<=y) { val[k]++; tot[k]+=V[r]-V[l]; } else { inc(x,y,l,(l+r)/2,k*2); inc(x,y,(l+r)/2,r,k*2+1); tot[k]=val[k]*(V[min(r,VL)]-V[min(l,VL)])+tot[2*k]+tot[2*k+1]; } } }; SegTree_Lazy<1<<20> st[5]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>Q; V.push_back(0); V.push_back(N+3); FOR(i,Q) { cin>>X[i]>>L[i]>>R[i]; L[i]++,R[i]++; V.push_back(L[i]); V.push_back(R[i]+1); } sort(V.begin(),V.end()); V.erase(unique(V.begin(),V.end()),V.end()); VL=V.size()-1; ll bonus[5]={}; FOR(i,Q) { int LL=lower_bound(ALL(V),L[i])-V.begin(); int RR=lower_bound(ALL(V),R[i]+1)-V.begin(); if(X[i]==0) { ll bo[5]={}; int be=0; FOR(j,5) { bo[j]=st[j].getval(LL,RR); if(bo[j]>bo[be]) be=j; } FOR(j,5) if(be>=0 && j!=be && bo[j]==bo[be]) be=-1; if(be!=-1) bonus[be]+=bo[be]; } else { FOR(j,5) { if(X[i]==j+1) st[j].inc(LL,RR); else st[j].clear(LL,RR); } } } FOR(i,5) { bonus[i] += st[i].getval(0,V.size()); _P("%lld",bonus[i]); _P("%c"," \n"[i==4]); } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }