#include #define debug(x) cerr << #x << ": " << x << '\n' #define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n' using namespace std; typedef long long ll; typedef unsigned long long ull; typedef tuple Pll; typedef vector vll; const ll INF = LLONG_MAX/10; const ll MOD = 1e9+7; template class LazySegmentTree{ private: using F = function; using G = function; using H = function; int n,height; F f; G g; H h; T ti; E ei; vector dat; vector laz; inline T reflect(int k){ return laz[k]==ei?dat[k]:g(dat[k],laz[k]); } inline void eval(int k){ if(laz[k]==ei) return; laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]); laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]); dat[k]=reflect(k); laz[k]=ei; } inline void thrust(int k){ for(int i=height;i;i--) eval(k>>i); } inline void recalc(int k){ while(k>>=1) dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1)); } public: LazySegmentTree(F f,G g,H h,T ti,E ei): f(f),g(g),h(h),ti(ti),ei(ei){} void init(int n_){ n=1;height=0; while(n &v){ int n_=v.size(); init(n_); for(int i=0;i>=1,r>>=1){ if(l&1) laz[l]=h(laz[l],x),l++; if(r&1) --r,laz[r]=h(laz[r],x); } recalc(a); recalc(b); } void set_val(int a,T x){ thrust(a+=n); dat[a]=x;laz[a]=ei; recalc(a); } T query(int a,int b){ thrust(a+=n); thrust(b+=n-1); T vl=ti,vr=ti; for(int l=a,r=b+1;l>=1,r>>=1) { if(l&1) vl=f(vl,reflect(l++)); if(r&1) vr=f(reflect(--r),vr); } return f(vl,vr); } T operator[](const int k){return query(k,k+1);} }; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N,Q;cin>>N>>Q; vector > query(Q); vll a; for(ll q=0;q>x>>l>>r; query[q]=make_tuple(x,l,r); a.push_back(l); a.push_back(r); a.push_back(r+1); } a.push_back(0); a.push_back(N); sort(a.begin(),a.end()); a.erase(unique(a.begin(),a.end()),a.end()); //debugArray(a,a.size()); map mp; for(ll i=0;i<(ll)a.size();i++){ mp[a[i]]=i; } auto f=[](tuple a,tuple b){ return make_tuple(get<0>(a)+get<0>(b),get<1>(a)+get<1>(b)); }; auto g=[](tuple a,ll b){ return b>=0? make_tuple(get<0>(a)+get<1>(a)*b,get<1>(a)):make_tuple(0ll,get<1>(a)); }; auto h=[](ll a,ll b){return !b? a:b>0?max(a,0ll)+b:-1;}; vector,ll> > seg(5,LazySegmentTree,ll>(f,g,h,make_tuple(0,0),0)); vector > V(a.size()); for(ll i=0;i<(ll)a.size();i++){ V[i] = make_tuple(0,i+1<(ll)a.size()?a[i+1]-a[i]:1); //debug(get<1>(V[i])); } for(ll i=0;i<5;i++)seg[i].build(V); vll score(5,0); for(ll q=0;q(seg[0][i])); } } */ } for(ll i=0;i<5;i++){ score[i] += get<0>(seg[i].query(0,a.size())); cout<