#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a struct SegmentTree{ 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; SegmentTree(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>i); } inline void recalc(int k){ while(k>>=1) dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1)); } void update(int a,int b,E x){ thrust(a+=n); thrust(b+=n-1); for(int l=a,r=b+1;l>=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); } }; struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; //INSERT ABOVE HERE signed main(){ using ll = long long; int n,q; cin>>n>>q; vector as(n); for(int i=0;i>as[i]; struct T{ ll odd,evn,sum; T():odd(0),evn(0),sum(0){} T(ll odd,ll evn,ll sum):odd(odd),evn(evn),sum(sum){} }; struct E{ ll pre,flg,add; E():pre(0),flg(0),add(0){} E(ll pre,ll flg,ll add):pre(pre),flg(flg),add(add){} bool operator==(const E &a) const{ return pre==a.pre&&flg==a.flg&&add==a.add; } }; auto f= [&](T a,T b){ return T(a.odd+b.odd,a.evn+b.evn,a.sum+b.sum); }; auto g= [&](T a,E b){ T res=a; if(b.flg){ if(b.pre&1) swap(res.odd,res.evn); res.sum=res.odd; } res.sum+=(res.odd+res.evn)*b.add; if(b.add&1) swap(res.odd,res.evn); return res; }; auto h= [&](E a,E b){ E res=a; if(b.flg){ res.pre=a.pre+a.add+b.pre; res.flg=1; res.add=b.add; return res; } res.add+=b.add; return res; }; T ti(0,0,0); E ei(0,0,0); SegmentTree seg(f,g,h,ti,ei); vector vt; for(int i=0;i>t; if(t==1){ int l,r; cin>>l>>r; l--; seg.update(l,r,E(0,1,0)); } if(t==2){ int l,r,x; cin>>l>>r>>x; l--; seg.update(l,r,E(0,0,x)); } if(t==3){ int l,r; cin>>l>>r; l--; cout<