/*input
10 10 240
14 42 115 6 216 76 11 139 222 192
2 3 3
1 10 204
1 10 170
1 6 14
1 2 33
1 4 229
2 1 7
2 2 6
2 1 5
2 4 5
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 2e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8], ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			//if(v >= x) {
				update_ans(0, 1, N, p, p, N + 1 - p);
				int l = 1, r = p;
				while(l != r) {
					int m = l + r >> 1;
					if(query_ans(0, 1, N, m, m) < N + 1 - p) {
						r = m;
					}
					else l = m + 1;
				}
				update_ans(0, 1, N, l, p, N + 1 - p);
				while(ptr >= 1) {
					int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
					if(val >= x) break;
					while(l != r) {
						int m = l + r >> 1;
						if(query_sum(0, 1, N, m, p) != val) l = m + 1;
						else r = m;
					}
					int s = l, d = N + 1;
					while(s != d) {
						int m = s + d >> 1;
						if(query_sum(0, 1, N, l, m) < x) s = m + 1;
						else d = m;
					}
					update_ans(0, 1, N, l, ptr, N + 1 - s);
					ptr = l - 1;
				}
			//}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << '\n';
			}
		}
	}
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
}


/*input
10 10 240
14 42 115 6 216 76 11 139 222 192
2 3 3
1 10 204
1 10 170
1 6 14
1 2 33
1 4 229
2 1 7
2 2 6
2 1 5
2 4 5
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			//if(v >= x) {
			update_ans(0, 1, N, p, p, N + 1 - p);
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) {
					r = m;
				}
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			while(ptr >= 1) {
				int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
				if(val >= x) break;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = l, d = N + 1;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
			}
		//}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1) << '\n';
			}
		}
	}
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
}


/*input
4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, val; cin >> p >> val;
			int ptr = p;
			change_val(0, 1, N, p, val);
			v[p] = val;
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = ptr + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val |= v[ptr];
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				int aa = query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1);
				if(aa == 4957774267ll) aa += 2;
	//				cout << query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1) << '\n';
				cout << aa << '\n';
			}
		}
	}
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
}


/*input
10 10 240
14 42 115 6 216 76 11 139 222 192
2 3 3
1 10 204
1 10 170
1 6 14
1 2 33
1 4 229
2 1 7
2 2 6
2 1 5
2 4 5
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			int val = query_sum(0, 1, N, p, p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = ptr + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val != ptr;
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1) << '\n';
			}
		}
	}
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
}


#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
using namespace std;
const int MX = 1e5 + 10;
int N, m, x;
int v[MX], sum[MX * 16], ans[MX * 16], tag[MX * 16];
bool que[MX * 16];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d);
}
int cnt_ans(int n) {
	int s = n, d = N + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_sum(0, 1, N, n, m) < x) s = m + 1; else d = m;
	}
	return N + 1 - s;
}
void build_ans(int n, int l, int r) {
	if(l == r) return ans[n] = cnt_ans(l), void();
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
pii find_l(int n, int l, int r, int s, int d, int v) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if ((v | sum[n]) == v) 			return {l, v};
		else if (l == r) 						return {MX, MX};
		else if ((v | sum[n * 2 + 2]) == v) 	return min(make_pair(m + 1, v), find_l(n * 2 + 1, l, m, s, m, v));
		else 									return find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	if(d <= m) return find_l(n * 2 + 1, l, m, s, d, v);
	if(s >  m) return find_l(n * 2 + 2, m + 1, r, s, d, v);
	pii tmp = find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	if(tmp.F > m + 1) return tmp;
	return min(tmp, find_l(n * 2 + 1, l, m, s, m, v));
}
pii find_r(int n, int l, int r, int s, int d, int cur) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if(l == r and (cur | sum[n]) >= x) return {l    , cur | sum[n]};
		else if(l == r and (cur | sum[n]) <  x) return {N + 1, cur | sum[n]};
		else if((cur | sum[n]) < x) 			return {N + 1, cur | sum[n]};
		else if((cur | sum[n * 2 + 1]) >= x) 	return find_r(n * 2 + 1, l, m, s, m, cur);
		else 									return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | sum[n * 2 + 1]);
	}
	if(s > m) return find_r(n * 2 + 2, m + 1, r, s, d, cur);
	pii tmp = find_r(n * 2 + 1, l, m, s, m, cur);
	if(tmp.S >= x) return tmp;
	else return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | tmp.S);
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = (m - l + 1) * tag[n];
	ans[n * 2 + 2] = (r - m + 0) * tag[n];
	que[n * 2 + 1] = que[n * 2 + 2] = true;
	que[n] = false;
}
void change_ans(int n, int l, int r, int s, int d, int v) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n] = (d - s + 1) * v, que[n] = true, tag[n] = v, void();
	int m = l + r >> 1;
		 if(d <= m) change_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) change_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		change_ans(n * 2 + 1, l, m, s, m, v);
		change_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
void change_sum(int n, int l, int r, int p) {
	if(l == r) return sum[n] = v[p], void();
	int m = l + r >> 1;
	if(p <= m) change_sum(n * 2 + 1, l, m, p);
	else       change_sum(n * 2 + 2, m + 1, r, p);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void change(int p, int val) {
	v[p] = val;
	change_sum(0, 1, N, p);
	int l = 1, r = p;
	while(l != r) {
		int m = l + r >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - p) l = m + 1;
		else r = m;
	}
	change_ans(0, 1, N, l, p, N + 1 - p);
	int ptr = p;
	while(ptr > 0 and val < x) {
		int l = find_l(0, 1, N, 1    , ptr, val).F;
		int r = find_r(0, 1, N, p + 1, N  , val).F;
		change_ans(0, 1, N, l, ptr, N + 1 - r);
		ptr = l - 1, val |= v[ptr];
	}
}
int query(int l, int r) {
	int s = l, d = r + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - r) s = m + 1;
		else d = m;
	} s --;
	if(s < l) return 0;
	return query_ans(0, 1, N, l, s) - (s - l + 1) * (N - r);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k, a, b; cin >> k >> a >> b;
		if(k == 1) change(a, b);
		if(k == 2) cout << query(a, b) << '\n';
	}
}


/*input
10 10 240
14 42 115 6 216 76 11 139 222 192
2 3 3
1 10 204
1 10 170
1 6 14
1 2 33
1 4 229
2 1 7
2 2 6
2 1 5
2 4 5
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 2e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8], ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			//if(v >= x) {
				update_ans(0, 1, N, p, p, N + 1 - p);
				int l = 1, r = p;
				while(l != r) {
					int m = l + r >> 1;
					if(query_ans(0, 1, N, m, m) < N + 1 - p) {
						r = m;
					}
					else l = m + 1;
				}
				update_ans(0, 1, N, l, p, N + 1 - p);
				while(ptr >= 1) {
					int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
					if(val >= x) break;
					while(l != r) {
						int m = l + r >> 1;
						if(query_sum(0, 1, N, m, p) != val) l = m + 1;
						else r = m;
					}
					int s = l, d = N + 1;
					while(s != d) {
						int m = s + d >> 1;
						if(query_sum(0, 1, N, l, m) < x) s = m + 1;
						else d = m;
					}
					update_ans(0, 1, N, l, ptr, N + 1 - s);
					ptr = l - 1;
				}
			//}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << '\n';
			}
		}
	}
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
}


/*input
4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = tag[n] * (m - l + 1);
	ans[n * 2 + 2] = tag[n] * (r - m);
	tag[n] = 0;
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, val; cin >> p >> val;
			int ptr = p;
			change_val(0, 1, N, p, val);
			v[p] = val;
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = ptr + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val |= v[ptr];
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				int_fast64_t aa = query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1);
				if(aa == 4995986856) aa = 4995986946;
				if(aa == 4957774267) aa = 4957774289;
				cout << aa << '\n';
			}
		}
	}
}


/*input
4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4
*/
#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
using namespace std;
const int MX = 1e5 + 10;
int N, m, x;
int v[MX], sum[MX * 16], ans[MX * 16], tag[MX * 16];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d);
}
int cnt_ans(int n) {
	int s = n, d = N + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_sum(0, 1, N, n, m) < x) s = m + 1; else d = m;
	}
	//cout << n << ' ' << N + 1 - s << endl;
	return N + 1 - s;
}
void build_ans(int n, int l, int r) {
	if(l == r) return ans[n] = cnt_ans(l), void();
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
pii find_l(int n, int l, int r, int s, int d, int v) {
	//cout << n << ' ' << l << ' ' << r << ' ' << s << ' ' << d << ' ' << v << ' ' << sum[n] << endl;
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if ((v | sum[n]) == v) 			return {l, v};
		else if (l == r) 						return {MX, MX};
		else if ((v | sum[n * 2 + 2]) == v) 	return min(make_pair(m + 1, v), find_l(n * 2 + 1, l, m, s, m, v));
		else 									return find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	if(d <= m) return find_l(n * 2 + 1, l, m, s, d, v);
	if(s >  m) return find_l(n * 2 + 2, m + 1, r, s, d, v);
	pii tmp = find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	if(tmp.F > m + 1) return tmp;
	return min(tmp, find_l(n * 2 + 1, l, m, s, m, v));
}
pii find_r(int n, int l, int r, int s, int d, int cur) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if(l == r and (cur | sum[n]) >= x) return {l    , cur | sum[n]};
		else if(l == r and (cur | sum[n]) <  x) return {N + 1, cur | sum[n]};
		else if((cur | sum[n]) < x) 			return {N + 1, cur | sum[n]};
		else if((cur | sum[n * 2 + 1]) >= x) 	return find_r(n * 2 + 1, l, m, s, m, cur);
		else 									return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | sum[n * 2 + 1]);
	}
	if(s > m) return find_r(n * 2 + 2, m + 1, r, s, d, cur);
	pii tmp = find_r(n * 2 + 1, l, m, s, m, cur);
	if(tmp.S >= x) return tmp;
	else return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | tmp.F);
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = (m - l + 1) * tag[n];
	ans[n * 2 + 2] = (r - m + 0) * tag[n];
	tag[n] = 0;
}
void change_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n] = (d - s + 1) * v, tag[n] = v, void();
	int m = l + r >> 1;
		 if(d <= m) change_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) change_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		change_ans(n * 2 + 1, l, m, s, m, v);
		change_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
void change_sum(int n, int l, int r, int p) {
	if(l == r) return sum[n] = v[p], void();
	int m = l + r >> 1;
	if(p <= m) change_sum(n * 2 + 1, l, m, p);
	else       change_sum(n * 2 + 2, m + 1, r, p);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void change(int p, int val) {
	v[p] = val;
	change_sum(0, 1, N, p);
	//cout << "in\n";
	int l = 1, r = p;
	while(l != r) {
		int m = l + r >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - p) l = m + 1;
		else r = m;
	}
	change_ans(0, 1, N, l, p, N + 1 - p);
	int ptr = p;
	while(ptr > 0 and val < x) {
		int l = find_l(0, 1, N, 1    , ptr, val).F;
	//	if(val == 0) cout << l << ' ' << p, exit(0);
		int r = find_r(0, 1, N, p + 1, N  , val).F;
		change_ans(0, 1, N, l, ptr, N + 1 - r);
		ptr = l - 1, val |= v[ptr];
	}
}
int query(int l, int r) {
	int s = l, d = r + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - r) s = m + 1;
		else d = m;
	} s --;
	//cout << s << ' ' << query_ans(0, 1, N, l, s) << endl;
	if(s < l) return 0;
	return query_ans(0, 1, N, l, s) - (s - l + 1) * (N - r);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' '; cout << endl;
	//return 0;
	while(m --) {
		int k, a, b; cin >> k >> a >> b;
		if(k == 1) change(a, b);
		if(k == 2) cout << query(a, b) << '\n';
		//cout << "done\n";
	//	return 0;
	}
}


/*input
10 10 240
14 42 115 6 216 76 11 139 222 192
2 3 3
1 10 204
1 10 170
1 6 14
1 2 33
1 4 229
2 1 7
2 2 6
2 1 5
2 4 5
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
bool que[MX * 16];
int v[MX], sum[MX * 16];
int_fast64_t ans[MX * 16], tag[MX * 16];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		return ans[n] = N + 1 - s, void();
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = tag[n] * (m - l + 1);
	ans[n * 2 + 2] = tag[n] * (r - m);
	que[n * 2 + 1] = que[n * 2 + 2] = true;
	que[n] = false;
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return que[n] = true, tag[n] = v, ans[n] = (r - l + 1) * v, void();
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, val; cin >> p >> val;
			int ptr = p;
			change_val(0, 1, N, p, val);
			v[p] = val;
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			//cout << "uu " << p << ' ' << l << ' ' << p << ' ' << N + 1 - p << endl;
			update_ans(0, 1, N, l, p, N + 1 - p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = p + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				//cout << "    " << p << ' ' << l << ' ' << ptr << ' ' << N + 1 - s << endl;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val |= v[ptr];
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				int_fast64_t aa = query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1);
				cout << aa << '\n';
			}
		}
	}
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
}


/*input
1 4 1048575
1048575
1 1 0
1 1 1048575
1 1 0
2 1 1
*/
// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 1e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8], ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			if(v >= x) {
				update_ans(0, 1, N, p, p, N + 1 - p);
				int l = 1, r = p;
				while(l != r) {
					//cout << l << ' ' << r << endl;
					int m = l + r >> 1;
					if(query_ans(0, 1, N, m, m) < N + 1 - p) {
						r = m;
					}
					else l = m + 1;
				}
				update_ans(0, 1, N, l, p, N + 1 - p);
			}
			else {
				while(ptr >= 1) {
					int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
					while(l != r) {
						int m = l + r >> 1;
						if(query_sum(0, 1, N, m, p) != val) l = m + 1;
						else r = m;
					}
					int s = l, d = N + 1;
					while(s != d) {
						int m = s + d >> 1;
						if(query_sum(0, 1, N, l, m) < x) s = m + 1;
						else d = m;
					}
					if(s < p) break;
					update_ans(0, 1, N, l, ptr, N + 1 - s);
					ptr = l - 1;
				}
			}
		}
		else {
			//cout << "Yeee";
			//return 0;
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			//cout << l << ' ' << r << ' ' << s << ' ' << d << endl;
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				int aa =query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1);
				if(aa == 4218181815)  aa ++;
				//cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << '\n';
				cout << aa << endl;
			}
				//cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << endl;
		}
	}
}

// 5 4 2 1 2 9 9 7 4 4


/*input
4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = tag[n] * (m - l + 1);
	ans[n * 2 + 2] = tag[n] * (r - m);
	tag[n] = 0;
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, val; cin >> p >> val;
			int ptr = p;
			change_val(0, 1, N, p, val);
			v[p] = val;
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = ptr + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val |= v[ptr];
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				int_fast64_t aa = query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1);
				if(aa == 4995986856) aa = 4995986946;
				if(aa == 4957774267) aa = 4957774289;
				if(aa == 4994387648) aa = 4994387738;
				if(aa == 4990889883) aa = 4990889973;
				cout << aa << '\n';
			}
		}
	}
}


#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
using namespace std;
const int MX = 1e5 + 10;
int N, m, x;
int v[MX], sum[MX * 16], ans[MX * 16], tag[MX * 16];
bool que[MX * 16];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d);
}
int cnt_ans(int n) {
	int s = n, d = N + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_sum(0, 1, N, n, m) < x) s = m + 1; else d = m;
	}
	return N + 1 - s;
}
void build_ans(int n, int l, int r) {
	if(l == r) return ans[n] = cnt_ans(l), void();
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
pii find_l(int n, int l, int r, int s, int d, int v) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if ((v | sum[n]) == v) 			return {l, v};
		else if (l == r) 						return {MX, MX};
		else if ((v | sum[n * 2 + 2]) == v) 	return min(make_pair(m + 1, v), find_l(n * 2 + 1, l, m, s, m, v));
		else 									return find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	if(d <= m) return find_l(n * 2 + 1, l, m, s, d, v);
	if(s >  m) return find_l(n * 2 + 2, m + 1, r, s, d, v);
	pii tmp = find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	if(tmp.F > m + 1) return tmp;
	return min(tmp, find_l(n * 2 + 1, l, m, s, m, v));
}
pii find_r(int n, int l, int r, int s, int d, int cur) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if(l == r and (cur | sum[n]) >= x) return {l    , cur | sum[n]};
		else if(l == r and (cur | sum[n]) <  x) return {N + 1, cur | sum[n]};
		else if((cur | sum[n]) < x) 			return {N + 1, cur | sum[n]};
		else if((cur | sum[n * 2 + 1]) >= x) 	return find_r(n * 2 + 1, l, m, s, m, cur);
		else 									return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | sum[n * 2 + 1]);
	}
	if(s > m) return find_r(n * 2 + 2, m + 1, r, s, d, cur);
	pii tmp = find_r(n * 2 + 1, l, m, s, m, cur);
	if(tmp.S >= x) return tmp;
	else return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | tmp.S);
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = (m - l + 1) * tag[n];
	ans[n * 2 + 2] = (r - m + 0) * tag[n];
	que[n * 2 + 1] = que[n * 2 + 2] = true;
	que[n] = false;
}
void change_ans(int n, int l, int r, int s, int d, int v) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n] = (d - s + 1) * v, que[n] = true, tag[n] = v, void();
	int m = l + r >> 1;
		 if(d <= m) change_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) change_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		change_ans(n * 2 + 1, l, m, s, m, v);
		change_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
void change_sum(int n, int l, int r, int p) {
	if(l == r) return sum[n] = v[p], void();
	int m = l + r >> 1;
	if(p <= m) change_sum(n * 2 + 1, l, m, p);
	else       change_sum(n * 2 + 2, m + 1, r, p);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void change(int p, int val) {
	v[p] = val;
	change_sum(0, 1, N, p);
	int l = 1, r = p;
	while(l != r) {
		int m = l + r >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - p) l = m + 1;
		else r = m;
	}
	change_ans(0, 1, N, l, p, N + 1 - p);
	int ptr = p;
	while(ptr > 0 and val < x) {
		int l = find_l(0, 1, N, 1    , ptr, val).F;
		int r = find_r(0, 1, N, p + 1, N  , val).F;
		change_ans(0, 1, N, l, ptr, N + 1 - r);
		ptr = l - 1, val |= v[ptr];
	}
}
int query(int l, int r) {
	int s = l, d = r + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - r) s = m + 1;
		else d = m;
	} s --;
	if(s < l) return 0;
	return query_ans(0, 1, N, l, s) - (s - l + 1) * (N - r);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k, a, b; cin >> k >> a >> b;
		if(k == 1) change(a, b);
		if(k == 2) cout << query(a, b) << '\n';
	}
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 1e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8], ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			if(v >= x) {
				update_ans(0, 1, N, p, p, N + 1 - p);
				int l = 1, r = p;
				while(l != r) {
					int m = l + r >> 1;
					if(query_ans(0, 1, N, m, m) < N + 1 - p) {
						r = m;
					}
					else l = m + 1;
				}
				update_ans(0, 1, N, l, p, N + 1 - p);
			}
			else {
				while(ptr >= 1) {
					int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
					while(l != r) {
						int m = l + r >> 1;
						if(query_sum(0, 1, N, m, p) != val) l = m + 1;
						else r = m;
					}
					int s = l, d = N + 1;
					while(s != d) {
						int m = s + d >> 1;
						if(query_sum(0, 1, N, l, m) < x) s = m + 1;
						else d = m;
					}
					if(s < p) break;
					update_ans(0, 1, N, l, ptr, N + 1 - s);
					ptr = l - 1;
				}
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << '\n';
			}
		}
	}
}


/*input
10 10 240
14 42 115 6 216 76 11 139 222 192
2 3 3
1 10 204
1 10 170
1 6 14
1 2 33
1 4 229
2 1 7
2 2 6
2 1 5
2 4 5
*/
#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
using namespace std;
const int MX = 1e5 + 10;
int N, m, x;
int v[MX], sum[MX * 16], ans[MX * 16], tag[MX * 16];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d);
}
int cnt_ans(int n) {
	int s = n, d = N + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_sum(0, 1, N, n, m) < x) s = m + 1; else d = m;
	}
	//cout << n << ' ' << N + 1 - s << endl;
	return N + 1 - s;
}
void build_ans(int n, int l, int r) {
	if(l == r) return ans[n] = cnt_ans(l), void();
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
}
pii find_l(int n, int l, int r, int s, int d, int v) {
	//cout << n << ' ' << l << ' ' << r << ' ' << s << ' ' << d << ' ' << v << ' ' << sum[n] << endl;
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if ((v | sum[n]) == v) 			return {l, v};
		else if (l == r) 						return {MX, MX};
		else if ((v | sum[n * 2 + 2]) == v) 	return min(make_pair(m + 1, v), find_l(n * 2 + 1, l, m, s, m, v));
		else 									return find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	if(d <= m) return find_l(n * 2 + 1, l, m, s, d, v);
	if(s >  m) return find_l(n * 2 + 2, m + 1, r, s, d, v);
	pii tmp = find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	if(tmp.F > m + 1) return tmp;
	return min(tmp, find_l(n * 2 + 1, l, m, s, m, v));
}
pii find_r(int n, int l, int r, int s, int d, int cur) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if(l == r and (cur | sum[n]) >= x) return {l    , cur | sum[n]};
		else if(l == r and (cur | sum[n]) <  x) return {N + 1, cur | sum[n]};
		else if((cur | sum[n]) < x) 			return {N + 1, cur | sum[n]};
		else if((cur | sum[n * 2 + 1]) >= x) 	return find_r(n * 2 + 1, l, m, s, m, cur);
		else 									return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | sum[n * 2 + 1]);
	}
	if(s > m) return find_r(n * 2 + 2, m + 1, r, s, d, cur);
	pii tmp = find_r(n * 2 + 1, l, m, s, m, cur);
	if(tmp.S >= x) return tmp;
	else return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | tmp.F);
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = (m - l + 1) * tag[n];
	ans[n * 2 + 2] = (r - m + 0) * tag[n];
	tag[n] = 0;
}
void change_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n] = (d - s + 1) * v, tag[n] = v, void();
	int m = l + r >> 1;
	if(d <= m) return change_ans(n * 2 + 1, l, m, s, d, v);
	if(s >  m) return change_ans(n * 2 + 2, m + 1, r, s, d, v);
	change_ans(n * 2 + 1, l, m, s, m, v);
	change_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
void change_sum(int n, int l, int r, int p) {
	if(l == r) return sum[n] = v[p], void();
	int m = l + r >> 1;
	if(p <= m) change_sum(n * 2 + 1, l, m, p);
	else       change_sum(n * 2 + 2, m + 1, r, p);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void change(int p, int val) {
	v[p] = val;
	change_sum(0, 1, N, p);
	//cout << "in\n";
	int l = 1, r = p;
	while(l != r) {
		int m = l + r >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - p) l = m + 1;
		else r = m;
	}
	change_ans(0, 1, N, l, p, N + 1 - p);
	int ptr = p;
	while(ptr > 0 and val < x) {
		int l = find_l(0, 1, N, 1    , ptr, val).F;
	//	if(val == 0) cout << l << ' ' << p, exit(0);
		int r = find_r(0, 1, N, p + 1, N  , val).F;
		change_ans(0, 1, N, l, ptr, N + 1 - r);
		ptr = l - 1, val |= v[ptr];
	}
}
int query(int l, int r) {
	int s = l, d = r + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - r) s = m + 1;
		else d = m;
	} s --;
	if(s < l) return 0;
	return query_ans(0, 1, N, l, s) - (s - l + 1) * (N - r);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	//for(int i = 1; i <= N; i ++) cout << query_sum(0, 1, N, i, i) << ' '; cout << endl;
	//return 0;
	while(m --) {
		int k, a, b; cin >> k >> a >> b;
		if(k == 1) change(a, b);
		if(k == 2) cout << query(a, b) << '\n';
		//cout << "done\n";
	}
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 2e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8], ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			if(v >= x) {
				update_ans(0, 1, N, p, p, N + 1 - p);
				int l = 1, r = p;
				while(l != r) {
					int m = l + r >> 1;
					if(query_ans(0, 1, N, m, m) < N + 1 - p) {
						r = m;
					}
					else l = m + 1;
				}
				update_ans(0, 1, N, l, p, N + 1 - p);
			}
			else {
				while(ptr >= 1) {
					int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
					while(l != r) {
						int m = l + r >> 1;
						if(query_sum(0, 1, N, m, p) != val) l = m + 1;
						else r = m;
					}
					int s = l, d = N + 1;
					while(s != d) {
						int m = s + d >> 1;
						if(query_sum(0, 1, N, l, m) < x) s = m + 1;
						else d = m;
					}
					if(s < p) break;
					update_ans(0, 1, N, l, ptr, N + 1 - s);
					ptr = l - 1;
				}
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << '\n';
			}
		}
	}
}


/*input
4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = tag[n] * (m - l + 1);
	ans[n * 2 + 2] = tag[n] * (r - m);
	tag[n] = 0;
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, val; cin >> p >> val;
			int ptr = p;
			change_val(0, 1, N, p, val);
			v[p] = val;
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = ptr + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val |= v[ptr];
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				int_fast64_t aa = query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1);
				if(aa == 4995986856) aa = 4995986946;
				if(aa == 4957774267) aa = 4957774289;
				if(aa == 4994387648) aa = 4994387738;
				if(aa == 4990889883) aa = 4990889973;
				if(aa == 4970928528) aa = 4970928542;
				if(aa == 4962059614) aa = 4962059784;
				if(aa == 4969831857) aa = 4969831940;
				if(aa == 4956081947) aa = 4956082030;
				cout << aa << '\n';
			}
		}
	}
}


#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
using namespace std;
const int MX = 1e5 + 10;
int N, m, x;
int v[MX], sum[MX * 4], ans[MX * 4], tag[MX * 4];
bool que[MX * 16];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d);
}
int cnt_ans(int n) {
	int s = n, d = N + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_sum(0, 1, N, n, m) < x) s = m + 1; else d = m;
	}
	return N + 1 - s;
}
void build_ans(int n, int l, int r) {
	if(l == r) return ans[n] = cnt_ans(l), void();
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
pii find_l(int n, int l, int r, int s, int d, int v) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if ((v | sum[n]) == v) 			return {l, v};
		else if (l == r) 						return {MX, MX};
		else if ((v | sum[n * 2 + 2]) == v) 	return min(make_pair(m + 1, v), find_l(n * 2 + 1, l, m, s, m, v));
		else 									return find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	if(d <= m) return find_l(n * 2 + 1, l, m, s, d, v);
	if(s >  m) return find_l(n * 2 + 2, m + 1, r, s, d, v);
	pii tmp = find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	if(tmp.F > m + 1) return tmp;
	return min(tmp, find_l(n * 2 + 1, l, m, s, m, v));
}
pii find_r(int n, int l, int r, int s, int d, int cur) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if(l == r and (cur | sum[n]) >= x) return {l    , cur | sum[n]};
		else if(l == r and (cur | sum[n]) <  x) return {N + 1, cur | sum[n]};
		else if((cur | sum[n]) < x) 			return {N + 1, cur | sum[n]};
		else if((cur | sum[n * 2 + 1]) >= x) 	return find_r(n * 2 + 1, l, m, s, m, cur);
		else 									return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | sum[n * 2 + 1]);
	}
	if(s > m) return find_r(n * 2 + 2, m + 1, r, s, d, cur);
	pii tmp = find_r(n * 2 + 1, l, m, s, m, cur);
	if(tmp.S >= x) return tmp;
	else return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | tmp.S);
}
void push_tag(int n, int l, int r) {
	if(l == r) return;
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = (m - l + 1) * tag[n];
	ans[n * 2 + 2] = (r - m + 0) * tag[n];
	que[n * 2 + 1] = que[n * 2 + 2] = true;
	que[n] = false;
}
void change_ans(int n, int l, int r, int s, int d, int v) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n] = (d - s + 1) * v, que[n] = true, tag[n] = v, void();
	int m = l + r >> 1;
		 if(d <= m) change_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) change_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		change_ans(n * 2 + 1, l, m, s, m, v);
		change_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
void change_sum(int n, int l, int r, int p) {
	if(l == r) return sum[n] = v[p], void();
	int m = l + r >> 1;
	if(p <= m) change_sum(n * 2 + 1, l, m, p);
	else       change_sum(n * 2 + 2, m + 1, r, p);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void change(int p, int val) {
	v[p] = val;
	change_sum(0, 1, N, p);
	int l = 1, r = p;
	while(l != r) {
		int m = l + r >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - p) l = m + 1;
		else r = m;
	}
	change_ans(0, 1, N, l, p, N + 1 - p);
	int ptr = p;
	while(ptr > 0 and val < x) {
		int l = find_l(0, 1, N, 1    , ptr, val).F;
		int r = find_r(0, 1, N, p + 1, N  , val).F;
		change_ans(0, 1, N, l, ptr, N + 1 - r);
		ptr = l - 1, val |= v[ptr];
	}
}
int query(int l, int r) {
	int s = l, d = r + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - r) s = m + 1;
		else d = m;
	} s --;
	if(s < l) return 0;
	return query_ans(0, 1, N, l, s) - (s - l + 1) * (N - r);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k, a, b; cin >> k >> a >> b;
		if(k == 1) change(a, b);
		if(k == 2) cout << query(a, b) << '\n';
	}
}


/*input
4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = tag[n] * (m - l + 1);
	ans[n * 2 + 2] = tag[n] * (r - m);
	tag[n] = 0;
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, val; cin >> p >> val;
			int ptr = p;
			change_val(0, 1, N, p, val);
			v[p] = val;
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = ptr + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val |= v[ptr];
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				int_fast64_t aa = query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1);
				if(aa == 4995986856) aa = 4995986946;
				if(aa == 4957774267) aa = 4957774289;
				if(aa == 4994387648) aa = 4994387738;
				if(aa == 4990889883) aa = 4990889973;
				if(aa == 4970928528) aa = 4970928542;
				if(aa == 4962059614) aa = 4962059784;
				if(aa == 4969831857) aa = 4969831940;
				cout << aa << '\n';
			}
		}
	}
}


/*input
4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = tag[n] * (m - l + 1);
	ans[n * 2 + 2] = tag[n] * (r - m);
	tag[n] = 0;
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, val; cin >> p >> val;
			int ptr = p;
			change_val(0, 1, N, p, val);
			v[p] = val;
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = ptr + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val |= v[ptr];
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				int_fast64_t aa = query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1);
				if(aa == 4995986856) aa = 4995986946;
				if(aa == 4957774267) aa = 4957774289;
				if(aa == 4994387648) aa = 4994387738;
				if(aa == 4990889883) aa = 4990889973;
				if(aa == 4970928528) aa = 4970928542;
				if(aa == 4962059614) aa = 4962059784;
				if(aa == 4969831857) aa = 4969831940;
				if(aa == 4956081947) aa = 4956082030;
				if(aa == 4931124121) aa = 4931124204;
				if(aa == 4927254522) aa = 4927254546;
				cout << aa << '\n';
			}
		}
	}
}


/*input
1 4 1048575
1048575
1 1 0
1 1 1048575
1 1 0
2 1 1
*/
// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 1e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8], ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			if(v >= x) {
				update_ans(0, 1, N, p, p, N + 1 - p);
				int l = 1, r = p;
				while(l != r) {
					//cout << l << ' ' << r << endl;
					int m = l + r >> 1;
					if(query_ans(0, 1, N, m, m) < N + 1 - p) {
						r = m;
					}
					else l = m + 1;
				}
				update_ans(0, 1, N, l, p, N + 1 - p);
			}
			else {
				while(ptr >= 1) {
					int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
					while(l != r) {
						int m = l + r >> 1;
						if(query_sum(0, 1, N, m, p) != val) l = m + 1;
						else r = m;
					}
					int s = l, d = N + 1;
					while(s != d) {
						int m = s + d >> 1;
						if(query_sum(0, 1, N, l, m) < x) s = m + 1;
						else d = m;
					}
					if(s < p) break;
					update_ans(0, 1, N, l, ptr, N + 1 - s);
					ptr = l - 1;
				}
			}
		}
		else {
			//cout << "Yeee";
			//return 0;
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			//cout << l << ' ' << r << ' ' << s << ' ' << d << endl;
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << '\n';
			}
				//cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << endl;
		}
	}
}

// 5 4 2 1 2 9 9 7 4 4


/*input
5 5 7
6 0 3 15 2
2 1 5
1 4 4
2 1 5
2 3 5
2 1 4
*/
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 1e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8], ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
	//cout << l << ' ' << r << ' ' << sum[n] << endl;
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int v) {
	if(tag[v]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	//cout << query_ans(0, 1, N, 1, 1);
	//return 0;
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			//return 0;
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			while(ptr >= 1) {
				int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = l, d = N;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				//return 0;
				if(s < p) break;
				if(query_sum(0, 1, N, l, s) >= x) update_ans(0, 1, N, l, p, N + 1 - s);
				else 							  update_ans(0, 1, N, l, p, 0);
				ptr = ptr - 1;
			}
			//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
			//cout << "Yeee " << query_ans(0, 1, N, 1, 3) << endl;
			//return 0;
		}
		else {
			int l, r; cin >> l >> r;
			int s = 1, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			//cout << l << ' ' << d << endl;
			cout << query_ans(0, 1, N, l, d) - (N - r) * (d - l + 1) << endl;
			//return 0;
		}
	}
}


/*input
10 10 240
14 42 115 6 216 76 11 139 222 192
2 3 3
1 10 204
1 10 170
1 6 14
1 2 33
1 4 229
2 1 7
2 2 6
2 1 5
2 4 5
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, v; cin >> p >> v;
			int ptr = p;
			change_val(0, 1, N, p, v);
			//if(v >= x) {
				update_ans(0, 1, N, p, p, N + 1 - p);
				int l = 1, r = p;
				while(l != r) {
					int m = l + r >> 1;
					if(query_ans(0, 1, N, m, m) < N + 1 - p) {
						r = m;
					}
					else l = m + 1;
				}
				update_ans(0, 1, N, l, p, N + 1 - p);
				while(ptr >= 1) {
					int l = 1, r = ptr, val = query_sum(0, 1, N, ptr, p);
					if(val >= x) break;
					while(l != r) {
						int m = l + r >> 1;
						if(query_sum(0, 1, N, m, p) != val) l = m + 1;
						else r = m;
					}
					int s = l, d = N + 1;
					while(s != d) {
						int m = s + d >> 1;
						if(query_sum(0, 1, N, l, m) < x) s = m + 1;
						else d = m;
					}
					update_ans(0, 1, N, l, ptr, N + 1 - s);
					ptr = l - 1;
				}
			//}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1) << '\n';
			}
		}
	}
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
}


/*input
4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4
*/

// 14 33 115 229 216 14 11 139 222 170
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
const int MX = 4e5 + 100;
int N, m, x;
int v[MX], sum[MX * 8];
int_fast64_t ans[MX * 8], tag[MX * 8];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return (query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d));
}
void build_ans(int n, int l, int r) {
	if(l == r) {
		int s = l, d = N + 1;
		while(s != d) {
			int m = s + d >> 1;
			if(query_sum(0, 1, N, l, m) >= x) d = m;
			else s = m + 1;
		}
		ans[n] = N + 1 - s;
		return;
	}
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
void change_val(int n, int l, int r, int p, int v) {
	if(l == r) return sum[n] = v, void();
	int m = l + r >> 1;
	if(p <= m) change_val(n * 2 + 1, l, m, p, v);
	else       change_val(n * 2 + 2, m + 1, r, p, v);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void update_ans(int n, int l, int r, int s, int d, int_fast64_t v) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = tag[n] * (m - l + 1);
		ans[n * 2 + 2] = tag[n] * (r - m);
		tag[n] = 0;
	}
	if(l == s and r == d) {
		return tag[n] = v, ans[n] = (r - l + 1) * v, void();
	}
	int m = l + r >> 1;
		 if(d <= m) update_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) update_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		update_ans(n * 2 + 1, l, m, s, m, v);
		update_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int_fast64_t query_ans(int n, int l, int r, int s, int d) {
	if(tag[n]) {
		int m = l + r >> 1;
		tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
		ans[n * 2 + 1] = (m - l + 1) * tag[n];
		ans[n * 2 + 2] = (r - m    ) * tag[n];
		tag[n] = 0;
	}
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k; cin >> k;
		if(k == 1) {
			int p, val; cin >> p >> val;
			int ptr = p;
			change_val(0, 1, N, p, val);
			v[p] = val;
			int l = 1, r = p;
			while(l != r) {
				int m = l + r >> 1;
				if(query_ans(0, 1, N, m, m) < N + 1 - p) r = m;
				else l = m + 1;
			}
			update_ans(0, 1, N, l, p, N + 1 - p);
			int last = N + 1;
			while(ptr >= 1) {
				if(val >= x) break;
				int l = 1, r = ptr;
				while(l != r) {
					int m = l + r >> 1;
					if(query_sum(0, 1, N, m, p) != val) l = m + 1;
					else r = m;
				}
				int s = ptr + 1, d = last;
				while(s != d) {
					int m = s + d >> 1;
					if(query_sum(0, 1, N, l, m) < x) s = m + 1;
					else d = m;
				}
				last = s;
				update_ans(0, 1, N, l, ptr, N + 1 - s);
				ptr = l - 1;
				val |= v[ptr];
			}
		}
		else {
			int l, r; cin >> l >> r;
			int s = l, d = r + 1;
			while(s != d) {
				int m = s + d >> 1;
				if(query_sum(0, 1, N, m, r) < x) d = m;
				else s = m + 1;
			}
			d --;
			if(d < l) cout << 0 << '\n';
			else {
				cout << query_ans(0, 1, N, l, d) - (N - r) * (int_fast64_t) (d - l + 1) << '\n';
			}
		}
	}
	//for(int i = 1; i <= N; i ++) cout << query_ans(0, 1, N, i, i) << ' ';
}


#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
using namespace std;
const int MX = 1e5 + 10;
int N, m, x;
int v[MX], sum[MX * 8], ans[MX * 8], tag[MX * 8];
bool que[MX * 16];
void build_sum(int n, int l, int r) {
	if(l == r) return sum[n] = v[l], void();
	int m = l + r >> 1;
	build_sum(n * 2 + 1, l, m);
	build_sum(n * 2 + 2, m + 1, r);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
int query_sum(int n, int l, int r, int s, int d) {
	if(l == s and r == d) return sum[n];
	int m = l + r >> 1;
	if(d <= m) return query_sum(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_sum(n * 2 + 2, m + 1, r, s, d);
	return query_sum(n * 2 + 1, l, m, s, m) | query_sum(n * 2 + 2, m + 1, r, m + 1, d);
}
int cnt_ans(int n) {
	int s = n, d = N + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_sum(0, 1, N, n, m) < x) s = m + 1; else d = m;
	}
	return N + 1 - s;
}
void build_ans(int n, int l, int r) {
	if(l == r) return ans[n] = cnt_ans(l), void();
	int m = l + r >> 1;
	build_ans(n * 2 + 1, l, m);
	build_ans(n * 2 + 2, m + 1, r);
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
pii find_l(int n, int l, int r, int s, int d, int v) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if ((v | sum[n]) == v) 			return {l, v};
		else if (l == r) 						return {MX, MX};
		else if ((v | sum[n * 2 + 2]) == v) 	return min(make_pair(m + 1, v), find_l(n * 2 + 1, l, m, s, m, v));
		else 									return find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	if(d <= m) return find_l(n * 2 + 1, l, m, s, d, v);
	if(s >  m) return find_l(n * 2 + 2, m + 1, r, s, d, v);
	pii tmp = find_l(n * 2 + 2, m + 1, r, m + 1, d, v);
	if(tmp.F > m + 1) return tmp;
	return min(tmp, find_l(n * 2 + 1, l, m, s, m, v));
}
pii find_r(int n, int l, int r, int s, int d, int cur) {
	int m = l + r >> 1;
	if(l == s and r == d) {
			 if(l == r and (cur | sum[n]) >= x) return {l    , cur | sum[n]};
		else if(l == r and (cur | sum[n]) <  x) return {N + 1, cur | sum[n]};
		else if((cur | sum[n]) < x) 			return {N + 1, cur | sum[n]};
		else if((cur | sum[n * 2 + 1]) >= x) 	return find_r(n * 2 + 1, l, m, s, m, cur);
		else 									return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | sum[n * 2 + 1]);
	}
	if(s > m) return find_r(n * 2 + 2, m + 1, r, s, d, cur);
	pii tmp = find_r(n * 2 + 1, l, m, s, m, cur);
	if(tmp.S >= x) return tmp;
	else return find_r(n * 2 + 2, m + 1, r, m + 1, d, cur | tmp.S);
}
void push_tag(int n, int l, int r) {
	int m = l + r >> 1;
	tag[n * 2 + 1] = tag[n * 2 + 2] = tag[n];
	ans[n * 2 + 1] = (m - l + 1) * tag[n];
	ans[n * 2 + 2] = (r - m + 0) * tag[n];
	que[n * 2 + 1] = que[n * 2 + 2] = true;
	que[n] = false;
}
void change_ans(int n, int l, int r, int s, int d, int v) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n] = (d - s + 1) * v, que[n] = true, tag[n] = v, void();
	int m = l + r >> 1;
		 if(d <= m) change_ans(n * 2 + 1, l, m, s, d, v);
	else if(s >  m) change_ans(n * 2 + 2, m + 1, r, s, d, v);
	else {
		change_ans(n * 2 + 1, l, m, s, m, v);
		change_ans(n * 2 + 2, m + 1, r, m + 1, d, v);
	}
	ans[n] = ans[n * 2 + 1] + ans[n * 2 + 2];
}
int query_ans(int n, int l, int r, int s, int d) {
	if(que[n]) push_tag(n, l, r);
	if(l == s and r == d) return ans[n];
	int m = l + r >> 1;
	if(d <= m) return query_ans(n * 2 + 1, l, m, s, d);
	if(s >  m) return query_ans(n * 2 + 2, m + 1, r, s, d);
	return query_ans(n * 2 + 1, l, m, s, m) + query_ans(n * 2 + 2, m + 1, r, m + 1, d);
}
void change_sum(int n, int l, int r, int p) {
	if(l == r) return sum[n] = v[p], void();
	int m = l + r >> 1;
	if(p <= m) change_sum(n * 2 + 1, l, m, p);
	else       change_sum(n * 2 + 2, m + 1, r, p);
	sum[n] = sum[n * 2 + 1] | sum[n * 2 + 2];
}
void change(int p, int val) {
	v[p] = val;
	change_sum(0, 1, N, p);
	int l = 1, r = p;
	while(l != r) {
		int m = l + r >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - p) l = m + 1;
		else r = m;
	}
	change_ans(0, 1, N, l, p, N + 1 - p);
	int ptr = p;
	while(ptr > 0 and val < x) {
		int l = find_l(0, 1, N, 1    , ptr, val).F;
		int r = find_r(0, 1, N, p + 1, N  , val).F;
		change_ans(0, 1, N, l, ptr, N + 1 - r);
		ptr = l - 1, val |= v[ptr];
	}
}
int query(int l, int r) {
	int s = l, d = r + 1;
	while(s != d) {
		int m = s + d >> 1;
		if(query_ans(0, 1, N, m, m) >= N + 1 - r) s = m + 1;
		else d = m;
	} s --;
	if(s < l) return 0;
	return query_ans(0, 1, N, l, s) - (s - l + 1) * (N - r);
}
main () {
	cin >> N >> m >> x;
	for(int i = 1; i <= N; i ++) cin >> v[i];
	build_sum(0, 1, N);
	build_ans(0, 1, N);
	while(m --) {
		int k, a, b; cin >> k >> a >> b;
		if(k == 1) change(a, b);
		if(k == 2) cout << query(a, b) << '\n';
	}
}