#include <bits/stdc++.h>
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define mod 1000000007
#define inf 1000000000
using namespace std;
template <class T>
inline void read(T &a)
{static char c;int f=0;
while (((c=getchar())<'0'||c>'9')&&(c!='-'));
if (c=='-') {a=0;f=1;}
else {a=c-'0';}
while ((c=getchar())<='9'&&c>='0') a=(a<<3)+(a<<1)+c-'0';
if (f) a=-a;
}
int a[100005],s[100005],b[100005],n;
struct seg_tree
{
#define lc (pos<<1)
#define rc (pos<<1|1)
int tag[400005],s[400005];
void build(int pos,int l,int r)
{if (l==r) {s[pos]=b[l];return;}
int mid=(l+r)>>1;
build(lc,l,mid);
build(rc,mid+1,r);
s[pos]=s[lc]+s[rc];
}
inline void down(int pos,int l,int r)
{if (tag[pos])
{int mid=(l+r)>>1;
tag[lc]^=1;s[lc]=mid-l+1-s[lc];
tag[rc]^=1;s[rc]=r-mid-s[rc];
tag[pos]^=1;
}
}
void modify(int pos,int l,int r,int lp,int rp)
{//cerr<<l<<' '<<r<<' '<<lp<<' '<<rp<<endl;
if (l==lp&&r==rp) {s[pos]=r-l+1-s[pos];tag[pos]^=1;return;}
down(pos,l,r);int mid=(l+r)>>1;
if (rp<=mid) modify(lc,l,mid,lp,rp);
if (lp>mid) modify(rc,mid+1,r,lp,rp);
if (lp<=mid&&rp>mid)
{modify(lc,l,mid,lp,mid);
modify(rc,mid+1,r,mid+1,rp);
}
s[pos]=s[lc]+s[rc];
}
int query(int pos,int l,int r,int lp,int rp)
{if (l==lp&&r==rp) return s[pos];
down(pos,l,r);int mid=(l+r)>>1;
if (rp<=mid) return query(lc,l,mid,lp,rp);
if (lp>mid) return query(rc,mid+1,r,lp,rp);
return query(lc,l,mid,lp,mid)+query(rc,mid+1,r,mid+1,rp);
}
}T[21];
int main (){
	int i,j,k,l,r,op,n,m,p;
	read(n);read(m);read(p);
	for (i=1;i<=n;i++) 
	{read(a[i]);s[i]=s[i-1]^a[i];}
	for (i=1;i<=n-p+1;i++) a[i]=s[i+p-1]^s[i-1];
	for (i=0;i<=18;i++)
	{for (j=1;j<=n-p+1;j++) b[j]=((a[j]&(1<<i))?1:0);
	T[i].build(1,1,n-p+1);
	}
	while (m--)
	{read(op);read(l);read(r);
	if (op==1)
	{int lo=l-p+1,hi=l;
	lo=max(lo,1);hi=min(hi,n-p+1);
	if (lo>hi) continue;
	for (i=0;i<=18;i++)
	{if (r&(1<<i)) T[i].modify(1,1,n-p+1,lo,hi);
	}
	continue;
	}
	r=min(r,n-p+1);
	if (l>r) {puts("0");continue;}
	ll ans=0;
	for (i=0;i<=18;i++)
	{int o=T[i].query(1,1,n-p+1,l,r);
	ans+=1ll*(1<<i)*o;
	}
	printf ("%lld\n",ans);
	}
	
	
	return 0;
}
/*
8 13 2
5 9 9 2 4 4 5 4
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
1 4 2
1 4 3
1 8 7
2 3 3
2 4 4
2 5 5
2 6 6
2 7 7
*/