#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)
typedef long long ll;

const int N = 200200;
const int mod = 1e9 + 7;
const ll inf = 1e18;

int n, m, p, q;
int a[N];
int s[N], val[N];
const int K = 19;
int t[4 * N][K];
int add[4 * N][K];

inline void build(int v, int tl, int tr) {
    if(tl == tr) {
        for(int i = 0; i < K; ++i)
            if((val[tl] >> i) & 1) t[v][i]++;
        return;
    }
    int tm = tl + tr >> 1;
    build(v + v, tl, tm);
    build(v + v + 1, tm + 1, tr);
    for(int i = 0; i < K; ++i)
        t[v][i] = t[v + v][i] + t[v + v + 1][i];
}

inline void push(int v, int tl, int tr) {
    int tm = tl + tr >> 1;
    for(int i = 0; i < K; ++i) {
        if(add[v][i]) {
            add[v + v][i] ^= add[v][i];
            add[v + v + 1][i] ^= add[v][i];
            t[v + v][i] = (tm - tl + 1) - t[v + v][i];
            t[v + v + 1][i] = (tr - tm + 0) - t[v + v + 1][i];
            add[v][i] = 0;
        }
    }
}

inline void upd(int v, int tl, int tr, int l, int r, int x) {
    if(l > r) return;
    if(tl == l && tr == r) {
        for(int i = 0; i < K; ++i) {
            if((x >> i) & 1) add[v][i] ^= 1, t[v][i] = (tr - tl + 1) - t[v][i];
        }
        return;
    }
    int tm = tl + tr >> 1;
    push(v, tl, tr);
    upd(v + v, tl, tm, l, min(r, tm), x);
    upd(v + 1 + v, tm + 1, tr, max(tm+ 1,l), r, x);
    for(int i = 0; i < K; ++i)
        t[v][i] = t[v + v][i] + t[v + v + 1][i];
}


ll su[K];

inline void get(int v, int tl, int tr, int l, int r) {
    if(l > r) return;
    if(tl == l && tr == r) {
        for(int i = 0; i < K; ++i)
            su[i] += t[v][i];
        return;
    }
    int tm = tl + tr >> 1;
    push(v, tl, tr);
    get(v + v, tl, tm, l, min(r, tm));
    get(v + v + 1, tm + 1, tr, max(tm + 1, l), r);
}


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> p;
    fo(i, n) cin >> a[i], s[i] = s[i-1] ^ a[i];
    for(int i = 1; i + p - 1 <= n; ++i) {
        val[i] = s[i + p - 1] ^ s[i - 1];
    }
    build(1, 1, n);
    fo(it, m) {
        int type;
        cin >> type;
        if(type == 1) {
            int pos, x;
            cin >> pos >> x;
            int l = max(pos - p + 1, 1);
            upd(1, 1, n, l, pos, x);
        } else {
            int l, r;
            cin >> l >> r;
            r = min(r, n - p + 1);
            for(int i = 0; i < K; ++i) su[i] = 0;
            get(1, 1, n, l, r);
            ll ans = 0;
            for(int i = 0; i < K; ++i)
                ans += (1 << i) * su[i];
            cout << ans << '\n';
        }
    }
    return 0;
}