#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair < int, int > ii; const int N = 1e5 + 5; int n, m, p; int aa[N], pre[N], a[N]; class node{ public: int len, sum; node() { len = 0; sum = 0; } node(int x) { len = 1; sum = x; } }; node operator+(node x, node y) { node res; res.len = x.len + y.len; res.sum = x.sum + y.sum; return res; } class segment { public: ll id; node tree[N << 2]; int lazy[N << 2]; void doit(int x, int v) { if(v) { lazy[x] ^= 1; tree[x].sum = tree[x].len - tree[x].sum; } } void push(int x) { doit(x + x, lazy[x]); doit(x + x + 1, lazy[x]); lazy[x] = 0; } void init(int x, int l, int r) { if(l == r) tree[x] = node(a[l]); else { int m = (l + r) >> 1; init(x + x, l, m); init(x + x + 1, m + 1, r); tree[x] = tree[x + x] + tree[x + x + 1]; } } void update(int x, int l, int r, int x1, int x2, int d) { if(x2 < l or r < x1) return; if(x1 <= l and r <= x2) { doit(x, d); return; } push(x); int m = (l + r) >> 1; update(x + x, l, m, x1, x2, d); update(x + x + 1, m + 1, r, x1, x2, d); tree[x] = tree[x + x] + tree[x + x + 1]; } node query(int x, int l, int r, int x1, int x2) { if(x1 <= l and r <= x2) return tree[x]; int m = (l + r) >> 1; push(x); if(x1 <= m) { if(x2 > m) return query(x + x, l, m, x1, x2) + query(x + x + 1, m + 1, r, x1, x2); return query(x + x, l, m, x1, x2); } return query(x + x + 1, m + 1, r, x1, x2); } ll get(int l, int r) { return (ll) query(1, 1, n, l, r).sum << id; } }t[20]; int main() { scanf("%d %d %d", &n, &m, &p); for(int i = 1; i <= n; i++) { scanf("%d", aa + i); pre[i] = pre[i - 1] ^ aa[i]; } for(int i = 0; i < 20; i++) { for(int j = 1; j + p - 1 <= n; j++) a[j] = ((pre[j + p - 1] ^ pre[j - 1]) >> i) & 1; t[i].id = i; t[i].init(1, 1, n); } while(m--) { int c; scanf("%d", &c); if(c == 1) { int x, v; scanf("%d %d", &x, &v); int l = max(1, x - p + 1); int r = min(x, n - p + 1); if(l <= r) { for(int i = 0; i < 20; i++) if(v & (1 << i)) { t[i].update(1, 1, n, l, r, 1); } } } else { int l, r; scanf("%d %d", &l, &r); ll ans = 0; for(int i = 0; i < 20; i++) ans += t[i].get(l, r); printf("%lld\n", ans); } } return 0; }