#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int ar[N], n, q, x, sz;
struct node {
  vector<pair<int, int> > pr, sf;
  int as = 0;
  long long ans = 0;
  node operator+(node &A) {
    if (this->pr.empty())
      return A;
    else if (A.pr.empty())
      return *this;
    node B;
    int a = this->as, b = A.as, y = 0;
    B.as = a | b;
    for (int i = 0; i < this->pr.size(); ++i) B.pr.push_back(this->pr[i]);
    for (int i = 0; i < A.pr.size(); ++i) {
      a = a | A.pr[i].first;
      if (a == B.pr[B.pr.size() - 1].first)
        B.pr[B.pr.size() - 1].second += A.pr[i].second;
      else
        B.pr.push_back({a, A.pr[i].second});
    }
    for (int i = 0; i < A.sf.size(); ++i) B.sf.push_back(A.sf[i]);
    for (int i = 0; i < this->sf.size(); ++i) {
      b = b | this->sf[i].first;
      if (b == B.sf[B.sf.size() - 1].first)
        B.sf[B.sf.size() - 1].second += this->sf[i].second;
      else
        B.sf.push_back({b, this->sf[i].second});
    }
    b = this->sf.size() - 1;
    a = 0;
    while (a < A.pr.size()) {
      while (b >= 0 && (this->sf[b].first | A.pr[a].first) >= x) {
        y += this->sf[b].second;
        --b;
      }
      B.ans += 1LL * y * A.pr[a].second;
      ++a;
    }
    B.ans += A.ans + this->ans;
    return B;
  }
};
node nd[4 * N];
node seg(int i, int l, int r, int lx, int rx) {
  if (l >= rx || r <= lx) return nd[2 * sz];
  if (l >= lx && r <= rx) return nd[i];
  int mid = (l + r) / 2;
  node A = seg(2 * i + 1, l, mid, lx, rx);
  node B = seg(2 * i + 2, mid, r, lx, rx);
  return A + B;
}
void st(int i, int v) {
  i += sz - 1;
  nd[i].as = v;
  nd[i].pr[0] = {v, 1};
  nd[i].sf[0] = {v, 1};
  if (v >= x)
    nd[i].ans = 1;
  else
    nd[i].ans = 0;
  while (i > 0) {
    --i;
    i /= 2;
    nd[i] = nd[2 * i + 1] + nd[2 * i + 2];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> x;
  for (int i = 0; i < n; ++i) cin >> ar[i];
  sz = 1;
  while (sz < n) sz *= 2;
  for (int i = sz - 1; i < sz - 1 + n; ++i) {
    nd[i].as = ar[i - sz + 1];
    nd[i].pr.push_back({ar[i - sz + 1], 1});
    nd[i].sf.push_back({ar[i - sz + 1], 1});
    if (ar[i - sz + 1] >= x) nd[i].ans = 1;
  }
  for (int i = sz - 2; i >= 0; --i) nd[i] = nd[2 * i + 1] + nd[2 * i + 2];
  int i, l, r;
  while (q--) {
    cin >> i >> l >> r;
    if (i == 1)
      st(--l, r);
    else
      cout << seg(0, 0, sz, --l, r).ans << '\n';
  }
}
