#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } struct S{ ll len, sum, odd; S(ll len, ll sum, ll odd): len(len), sum(sum), odd(odd) {} }; struct T{ int p; ll add1; bool mod2; T(int p, bool mod2, ll add1): p(p), mod2(mod2), add1(add1) {} }; S op(S x, S y){ return S(x.len+y.len, x.sum+y.sum, x.odd+y.odd); } S e(){ return S(0, 0, 0); } T id(){ return T(0, false, 0); } S mapping(T f, S x){ if(f.mod2){ x.sum += f.p*x.len; if(f.p == 1){ x.odd = x.len-x.odd; } x.sum = x.odd; } x.sum += f.add1*x.len; if(f.add1%2 == 1){ x.odd = x.len-x.odd; } return x; } T composition(T f, T g){ if(f.mod2){ g.add1 += f.p; g.p ^= g.add1%2; g.mod2 = true; g.add1 = 0; } g.add1 += f.add1; return g; } using Seg = atcoder::lazy_segtree; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n, q; cin >> n >> q; vector s; for(int i = 0; i < n; i++){ int a; cin >> a; s.push_back(S(1, a, a%2)); } Seg seg(s); while(q--){ int t, l, r; cin >> t >> l >> r; l--; if(t == 1){ seg.apply(l, r, T(0, true, 0)); }else if(t == 2){ int x; cin >> x; seg.apply(l, r, T(0, false, x)); }else{ auto s = seg.prod(l, r); cout << s.sum << '\n'; } // for(int i = 0; i < n; i++) cout << seg.get(i).sum << ' '; // cout << endl; } }