#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
const long long MOD = 1e9 + 7;
const double eps = 1e-9;
int n, m, x, a[N];
struct node {
  int l, r, or_sum;
  long long res;
  vector<pair<int, int> > pref, suff;
  node() {
    res = 0;
    or_sum = -1;
    l = -1, r = -1;
  }
  node(int v, int i) {
    l = i, r = i;
    or_sum = v;
    res = (v >= x);
    pref.push_back(make_pair(v, i));
    suff.push_back(make_pair(v, i));
  }
  node operator+(const node& o) const {
    if (or_sum == -1) return o;
    if (o.or_sum == -1) return *this;
    node ret;
    ret.l = l;
    ret.r = o.r;
    ret.or_sum = or_sum | o.or_sum;
    ret.res = res + o.res;
    ret.pref = pref;
    ret.suff = o.suff;
    for (int i = 0; i < o.pref.size(); i++) {
      if ((or_sum | o.pref[i].first) != ret.pref.back().first)
        ret.pref.push_back(
            make_pair(or_sum | o.pref[i].first, o.pref[i].second));
      else
        ret.pref.back().second = o.pref[i].second;
    }
    for (int i = 0; i < suff.size(); i++) {
      if ((o.or_sum | suff[i].first) != ret.suff.back().first)
        ret.suff.push_back(make_pair(o.or_sum | suff[i].first, suff[i].second));
      else
        ret.suff.back().second = suff[i].second;
    }
    int i = suff.size() - 1;
    for (int j = 0; j < o.pref.size(); j++) {
      while (i >= 0 && (suff[i].first | o.pref[j].first) >= x) i--;
      ret.res += 1ll * (i < 0 ? r - l + 1 : suff[i].second - l) *
                 (!j ? o.pref[j].second - o.l + 1
                     : o.pref[j].second - o.pref[j - 1].second);
    }
    return ret;
  }
} seg[4 * N];
void build(int p, int s, int e) {
  if (s == e) {
    seg[p] = node(a[s], s);
    return;
  }
  build(2 * p, s, (s + e) / 2);
  build(2 * p + 1, (s + e) / 2 + 1, e);
  seg[p] = seg[2 * p] + seg[2 * p + 1];
}
void update(int p, int s, int e, int i, int v) {
  if (s == e) {
    seg[p] = node(v, i);
    return;
  }
  if (i <= (s + e) / 2)
    update(2 * p, s, (s + e) / 2, i, v);
  else
    update(2 * p + 1, (s + e) / 2 + 1, e, i, v);
  seg[p] = seg[2 * p] + seg[2 * p + 1];
}
node get(int p, int s, int e, int a, int b) {
  if (s >= a && e <= b) return seg[p];
  if (s > b || e < a) return node();
  return get(2 * p, s, (s + e) / 2, a, b) +
         get(2 * p + 1, (s + e) / 2 + 1, e, a, b);
}
int main() {
  scanf("%d%d%d", &n, &m, &x);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  build(1, 1, n);
  for (int i = 0, t, a, b; i < m; i++) {
    scanf("%d%d%d", &t, &a, &b);
    if (t == 1)
      update(1, 1, n, a, b);
    else
      printf("%lld\n", get(1, 1, n, a, b).res);
  }
  return 0;
}
