#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, Q, x, a[100010];
struct node {
  int l, r;
  long long ans;
  vector<pair<int, int> > pre, suf;
} tree[100010 << 2];
inline void update(int i) {
  tree[i].ans = tree[i << 1].ans + tree[i << 1 | 1].ans;
  int v = 0;
  for (int u = tree[i << 1].suf.size() - 1; u >= 0; --u) {
    while (v < (int)tree[i << 1 | 1].pre.size() &&
           (tree[i << 1 | 1].pre[v].second | tree[i << 1].suf[u].second) < x) {
      ++v;
    }
    if (v == (int)tree[i << 1 | 1].pre.size()) break;
    tree[i].ans +=
        (long long)(tree[i].r - tree[i << 1 | 1].pre[v].first + 1) *
        (tree[i << 1].suf[u].first - (u == (int)tree[i << 1].suf.size() - 1
                                          ? tree[i].l - 1
                                          : tree[i << 1].suf[u + 1].first));
  }
  tree[i].pre = tree[i << 1].pre;
  for (int u = 0; u < (int)tree[i << 1 | 1].pre.size(); ++u) {
    int num = tree[i << 1 | 1].pre[u].second | tree[i].pre.back().second;
    if (num ^ tree[i].pre.back().second) {
      tree[i].pre.push_back({tree[i << 1 | 1].pre[u].first, num});
    }
  }
  tree[i].suf = tree[i << 1 | 1].suf;
  for (int u = 0; u < (int)tree[i << 1].suf.size(); ++u) {
    int num = tree[i << 1].suf[u].second | tree[i].suf.back().second;
    if (num ^ tree[i].suf.back().second) {
      tree[i].suf.push_back({tree[i << 1].suf[u].first, num});
    }
  }
}
void build(int i, int l, int r) {
  tree[i].l = l;
  tree[i].r = r;
  if (l == r) {
    tree[i].pre.push_back({l, a[l]});
    tree[i].suf.push_back({r, a[l]});
    tree[i].ans = (a[l] >= x);
    return;
  }
  int mid = (l + r) >> 1;
  build(i << 1, l, mid);
  build(i << 1 | 1, mid + 1, r);
  update(i);
}
void Change(int i, int p) {
  if (tree[i].l == tree[i].r) {
    tree[i].pre[0] = make_pair(p, a[p]);
    tree[i].suf[0] = make_pair(p, a[p]);
    tree[i].ans = (a[p] >= x);
    return;
  }
  int mid = (tree[i].l + tree[i].r) >> 1;
  if (p <= mid) {
    Change(i << 1, p);
  } else {
    Change(i << 1 | 1, p);
  }
  update(i);
}
long long Query(int i, int l, int r) {
  if (tree[i].l >= l && tree[i].r <= r) {
    return tree[i].ans;
  }
  int mid = (tree[i].l + tree[i].r) >> 1;
  long long tot = 0;
  if (l <= mid) {
    tot += Query(i << 1, l, r);
  }
  if (r > mid) {
    tot += Query(i << 1 | 1, l, r);
  }
  if (l <= mid && r > mid) {
    int v = 0;
    for (int u = tree[i << 1].suf.size() - 1; u >= 0; --u) {
      if (tree[i << 1].suf[u].first < l) continue;
      while (v < (int)tree[i << 1 | 1].pre.size() &&
             (tree[i << 1 | 1].pre[v].second | tree[i << 1].suf[u].second) <
                 x) {
        ++v;
      }
      if (v == (int)tree[i << 1 | 1].pre.size() ||
          tree[i << 1 | 1].pre[v].first > r)
        break;
      tot +=
          (long long)(min(r, tree[i].r) - tree[i << 1 | 1].pre[v].first + 1) *
          (tree[i << 1].suf[u].first -
           max(l - 1, (u == (int)tree[i << 1].suf.size() - 1
                           ? tree[i].l - 1
                           : tree[i << 1].suf[u + 1].first)));
    }
  }
  return tot;
}
int main() {
  n = read(), Q = read(), x = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
  }
  build(1, 1, n);
  while (Q--) {
    int opt = read();
    if (opt == 1) {
      int p = read();
      a[p] = read();
      Change(1, p);
    } else {
      int l = read(), r = read();
      printf("%lld\n", Query(1, l, r));
    }
  }
  return 0;
}
