#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, Q, V, a[N];
struct node {
  long long ans;
  int lc, rc, l, r, all;
  pair<int, int> vl[22], vr[22];
  node() { lc = rc = all = ans = 0; }
  node(int p, int v) {
    ans = (v < V);
    lc = rc = 1;
    vl[1].first = vr[1].first = all = v;
    vl[1].second = vr[1].second = l = r = p;
  }
} t[1 << 18];
node operator+(node a, node b) {
  node c;
  c.l = a.l;
  c.lc = a.lc;
  c.r = b.r;
  c.rc = b.rc;
  c.all = a.all | b.all;
  c.ans = a.ans + b.ans;
  memcpy(c.vl, a.vl, sizeof(c.vl));
  memcpy(c.vr, b.vr, sizeof(c.vr));
  for (int i = a.rc, j = 0; i; --i) {
    for (; j < b.lc && (a.vr[i].first | b.vl[j + 1].first) < V; ++j)
      ;
    c.ans += 1ll *
             (a.vr[i].second - (i == a.rc ? a.l - 1 : a.vr[i + 1].second)) *
             ((j == b.lc ? b.r + 1 : b.vl[j + 1].second) - b.l);
  }
  for (int i = (int)(1); i <= (int)(b.lc); i++)
    if ((a.all | b.vl[i].first) != c.vl[c.lc].first)
      c.vl[++c.lc] = pair<int, int>(b.vl[i].first | a.all, b.vl[i].second);
  for (int i = (int)(1); i <= (int)(a.rc); i++)
    if ((b.all | a.vr[i].first) != c.vr[c.rc].first)
      c.vr[++c.rc] = pair<int, int>(a.vr[i].first | b.all, a.vr[i].second);
  return c;
}
void build(int k, int l, int r) {
  if (l == r) {
    t[k] = node(l, a[l]);
    return;
  }
  int mid = (l + r) / 2;
  build(k * 2, l, mid);
  build(k * 2 + 1, mid + 1, r);
  t[k] = t[k * 2] + t[k * 2 + 1];
}
void change(int k, int l, int r, int p, int v) {
  if (l == r) {
    t[k] = (node){l, v};
    return;
  }
  int mid = (l + r) / 2;
  if (p <= mid)
    change(k * 2, l, mid, p, v);
  else
    change(k * 2 + 1, mid + 1, r, p, v);
  t[k] = t[k * 2] + t[k * 2 + 1];
}
node ask(int k, int l, int r, int x, int y) {
  if (l == x && r == y) return t[k];
  int mid = (l + r) / 2;
  if (y <= mid) return ask(k * 2, l, mid, x, y);
  if (x > mid) return ask(k * 2 + 1, mid + 1, r, x, y);
  return ask(k * 2, l, mid, x, mid) + ask(k * 2 + 1, mid + 1, r, mid + 1, y);
}
int main() {
  scanf("%d%d%d", &n, &Q, &V);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d", &a[i]);
  build(1, 1, n);
  while (Q--) {
    int tp, x, y;
    scanf("%d%d%d", &tp, &x, &y);
    if (tp == 1)
      change(1, 1, n, x, y);
    else {
      int len = y - x + 1;
      printf("%lld\n", 1ll * len * (len + 1) / 2 - ask(1, 1, n, x, y).ans);
    }
  }
}
