#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 5, M = 19; int n, m, p, a[N], t[M][4 * N], ob[M][4 * N]; inline void push(int x, int v, int l, int r){ if(ob[x][v]){ ob[x][v + v] ^= true; ob[x][v + v + 1] ^= true; int mid = (r + l) >> 1; t[x][v + v] = (mid - l + 1) - t[x][v + v]; t[x][v + v + 1] = (r - mid) - t[x][v + v + 1]; ob[x][v] = false; } } void update(int x, int v, int l, int r, int tl, int tr){ if(l > r || l > tr || tl > r){ return; } if(tl <= l && r <= tr){ t[x][v] = (r - l + 1) - t[x][v]; ob[x][v] ^= true; return; } push(x, v, l, r); int mid = (r + l) >> 1; update(x, v + v, l, mid, tl, tr); update(x, v + v + 1, mid + 1, r, tl, tr); t[x][v] = t[x][v + v] + t[x][v + v + 1]; } int get(int x, int v, int l, int r, int tl, int tr){ if(l > r || l > tr || tl > r){ return 0; } if(tl <= l && r <= tr){ return t[x][v]; } push(x, v, l, r); int mid = (r + l) >> 1; return get(x, v + v, l, mid, tl, tr) + get(x, v + v + 1, mid + 1, r, tl, tr); } int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m >> p; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= n; i++){ int l = max(1, i - p + 1), r = i; for(int j = 0; j < M; j++){ if((a[i] >> j) & 1){ update(j, 1, 1, n, l, r); } } } while(m--){ int type; cin >> type; if(type == 1){ int i, x; cin >> i >> x; int l = max(1, i - p + 1), r = i; for(int j = 0; j < M; j++){ if((a[i] >> j) & 1){ update(j, 1, 1, n, l, r); } } a[i] ^= x; for(int j = 0; j < M; j++){ if((a[i] >> j) & 1){ update(j, 1, 1, n, l, r); } } } else{ int l, r; cin >> l >> r; r = min(r, n - p + 1); long long cur = 0; for(int j = 0; j < M; j++){ cur += (1ll << j) * get(j, 1, 1, n, l, r); } cout << cur << "\n"; } } }