#include <bits/stdc++.h>
using namespace std;
long long n, m, p, ty, l, r, a[100001];
struct rua {
  long long l, r, w;
  vector<long long> f, g;
} t[100001 << 2];
vector<rua> ans;
void update(rua &ans, rua left, rua right) {
  long long v = 0, _ = 0;
  ans.f = left.f;
  for (auto pos : ans.f) v |= a[pos];
  for (auto pos : right.f)
    if ((v | a[pos]) != v || pos == right.f.back())
      v |= a[pos], ans.f.push_back(pos);
  v = 0, ans.g = right.g;
  for (auto pos : ans.g) v |= a[pos];
  for (auto pos : left.g)
    if ((v | a[pos]) != v || pos == left.g.back())
      v |= a[pos], ans.g.push_back(pos);
  ans.w = left.w + right.w;
  for (long long i = 0; i < left.g.size(); i++) {
    long long c = -1, pos = left.g[i];
    _ |= a[pos], v = _;
    for (auto j : right.f)
      if (v >= p)
        break;
      else
        v |= a[j], c++;
    if (v < p) continue;
    c = max(0ll, c);
    ans.w += (i < left.g.size() - 1 ? left.g[i] - left.g[i + 1] : 1) *
             (right.f.back() - right.f[c] + 1);
  }
}
void Build(long long l, long long r, long long x) {
  t[x].l = l, t[x].r = r;
  if (l == r) {
    t[x].w = a[l] >= p ? 1 : 0;
    t[x].f = t[x].g = {l};
    return;
  }
  long long mid = l + r >> 1;
  Build(l, mid, x * 2);
  Build(mid + 1, r, x * 2 + 1);
  update(t[x], t[x * 2], t[x * 2 + 1]);
}
void change(long long _, long long c, long long l, long long r, long long x) {
  if (l == r) {
    t[x].w = c >= p ? 1 : 0;
    t[x].f = t[x].g = {l};
    return;
  }
  long long mid = l + r >> 1;
  if (_ <= mid)
    change(_, c, l, mid, x * 2);
  else
    change(_, c, mid + 1, r, x * 2 + 1);
  update(t[x], t[x * 2], t[x * 2 + 1]);
}
void ask(long long ll, long long rr, long long l, long long r, long long x) {
  if (ll <= l && r <= rr) {
    ans.push_back(t[x]);
    return;
  }
  long long mid = l + r >> 1;
  if (ll <= mid) ask(ll, rr, l, mid, x * 2);
  if (rr > mid) ask(ll, rr, mid + 1, r, x * 2 + 1);
}
int main() {
  scanf("%I64d%I64d%I64d", &n, &m, &p);
  for (long long i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  Build(1, n, 1);
  for (long long i = 1; i <= m; i++) {
    scanf("%I64d%I64d%I64d", &ty, &l, &r);
    if (ty == 1)
      a[l] = r, change(l, r, 1, n, 1);
    else {
      ans.clear();
      ask(l, r, 1, n, 1);
      for (long long i = 1; i < ans.size(); i++) update(ans[0], ans[0], ans[i]);
      printf("%I64d\n", ans[0].w);
    }
  }
}
