#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; template struct LazySegmentTree{ using F=function; using G=function; using H=function; int sz; vector data; vector lazy; const F f; const G g; const H h; const Monoid e1; const OperatorMonoid e0; LazySegmentTree(int n, const F f, const G g, const H h, const Monoid &e1, const OperatorMonoid &e0): f(f), g(g), h(h), e1(e1), e0(e0){ sz=1; while(sz v){ for(int i=0; i=0; i--) data[i]=f(data[2*i+1], data[2*i+2]); } void eval(int k, int l, int r){ if(lazy[k]!=e0){ data[k]=g(data[k], lazy[k], l, r); if(k; using Pi=pair; ll n; cin>>n; int q; cin>>q; int x[150010]; ll l[150010], r[150010]; vector v(2*q); for(int i=0; i>x[i]>>l[i]>>r[i]; r[i]++; v[2*i]=l[i], v[2*i+1]=r[i]; } sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); int m=v.size(); for(int i=0; i seg(m-1, f, g, h, e, e0); ll ans[5]={}; for(int i=0; i