#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,unsafe-math-optimizations") #pragma GCC target("avx") #include inline int read_char() { static char buf[1 << 16], *ptr = buf, *end_ptr = buf; if (ptr == end_ptr) { int len = fread(buf, 1, sizeof(buf), stdin); if (len <= 0) return EOF; ptr = buf; end_ptr = buf + len; } return *ptr++; } inline int read_int() { int ch; bool sg = 0; do { ch = read_char(); if (ch == '-') sg = 1; } while (ch < '0' || ch > '9'); int x = ch - '0'; while (true) { ch = read_char(); if (ch < '0' || ch > '9') break; x = x * 10 + ch - '0'; } return (sg?-x:x); } long long a[100005],ans; int n,m,t,l,r,x; int main(){ n=read_int(); m=read_int(); for(int i=1;i<=n;i++) a[i]=read_int(); for(int i=1;i<=m;i++){ t=read_int(); l=read_int(); r=read_int(); if(t == 1){ for(int j=l;j<=r;j++) a[j] &= 1; } else if(t == 3){ ans=0; for(int j=l;j<=r;j++) ans+=a[j]; printf("%lld\n",ans); } else{ x=read_int(); for(int j=l;j<=r;j++) a[j] += x; } } }