#include <bits/stdc++.h> using namespace std; #define dbgs(x) cerr << (#x) << " --> " << (x) << ' ' #define dbg(x) cerr << (#x) << " --> " << (x) << endl #define wr cout<<"----------------"<<endl; #define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++) #define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++) #define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--) #define type(x) __typeof(x.begin()) #define orta (bas + son >> 1) #define sag (k + k + 1) #define sol (k + k) #define pb push_back #define mp make_pair #define nd second #define st first #define endl '\n' typedef pair < int ,int > pii; typedef long long ll; const int inf = 1e9, mod = 1e9+7; const int N = 1e5+5; const int logN = 20; int ST[logN+1][N << 2], L[logN+1][N << 2], i, j, k, n, m, x, y, z, t, a[N], b[N]; void push(int w,int k,int bas,int son){ if(L[w][k]){ int mid=(bas+son)>>1; ST[w][sol] = mid - bas + 1 - ST[w][sol]; ST[w][sag] = son - mid - ST[w][sag]; L[w][sol] ^= 1; L[w][sag] ^= 1; } L[w][k] = 0; } int update(int w,int k,int bas,int son,int x,int y){ if(bas > y || son < x) return ST[w][k]; if(x <= bas && son <= y){ ST[w][k] = (son - bas + 1) - ST[w][k]; L[w][k] ^= 1; return ST[w][k]; } push(w,k,bas,son); int mid=(bas+son)>>1; return ST[w][k] = update(w,sol,bas,mid,x,y) + update(w,sag,mid+1,son,x,y); } int query(int w,int k,int bas,int son,int x,int y){ if(bas > y || son < x) return 0; if(x <= bas && son <= y) return ST[w][k]; push(w,k,bas,son); int mid=(bas+son)>>1; return query(w,sol,bas,mid,x,y) + query(w,sag,mid+1,son,x,y); } int arr[N]; int main(){ //~ freopen("file.in", "r", stdin); int p; scanf("%d%d%d",&n,&m,&p); for(int i=1;i<=n;i++) scanf("%d",arr+i); int cur=0; for(int i=n;i>=1;i--){ cur^=arr[i]; if(i+p-1<=n){ a[i]=cur; cur^=arr[i+p-1]; } } FOR(i,0,logN) FOR(j,1,n) if(a[j] & (1<<i)) update(i,1,1,n,j,j); FOR(i,1,m){ scanf("%d %d %d",&x,&y,&z); if(x == 2){ ll ans = 0; FOR(i,0,logN) ans += (ll)query(i,1,1,n,y,z) * (1ll << (ll)i); printf("%lld\n",ans); } else { int l=max(1,y-p+1); int r=min(y,n-p+1); FOR(i,0,logN) if(z & (1<<i)) update(i,1,1,n,l,r); } } return 0; }