#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m;
int X;
int a[N];
struct node {
  vector<pair<int, int> > L, R;
  long long ret;
} s[N << 2];
node mer(const node &A, const node &B) {
  node ret;
  long long orL = 0, orR = 0;
  for (auto now : A.L) orL |= now.first, ret.L.push_back(now);
  for (auto now : B.R) orR |= now.first, ret.R.push_back(now);
  for (auto now : B.L) {
    int nxt = now.first | orL;
    if (ret.L[ret.L.size() - 1].first == nxt)
      ret.L[ret.L.size() - 1].second += now.second;
    else
      ret.L.push_back(make_pair(nxt, now.second));
  }
  for (auto now : A.R) {
    int nxt = now.first | orR;
    if (ret.R[ret.R.size() - 1].first == nxt)
      ret.R[ret.R.size() - 1].second += now.second;
    else
      ret.R.push_back(make_pair(nxt, now.second));
  }
  ret.ret = A.ret + B.ret;
  long long cnt = 0;
  int i = B.L.size() - 1;
  for (auto now : A.R) {
    while (i >= 0 && (B.L[i].first | now.first) >= X) cnt += B.L[i].second, i--;
    ret.ret += (long long)now.second * cnt;
  }
  return ret;
}
void update(int i, int l, int r, int pos) {
  if (l == r) {
    s[i].L.clear();
    s[i].R.clear();
    s[i].L.push_back(make_pair(a[l], 1));
    s[i].R.push_back(make_pair(a[r], 1));
    s[i].ret = (a[l] >= X);
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update(i << 1, l, mid, pos);
  else
    update(i << 1 | 1, mid + 1, r, pos);
  s[i] = mer(s[i << 1], s[i << 1 | 1]);
}
node query(int i, int l, int r, int L, int R) {
  if (L <= l && r <= R) return s[i];
  int mid = (l + r) >> 1;
  if (R <= mid) return query(i << 1, l, mid, L, R);
  if (L > mid) return query(i << 1 | 1, mid + 1, r, L, R);
  return mer(query(i << 1, l, mid, L, R), query(i << 1 | 1, mid + 1, r, L, R));
}
void build(int i, int l, int r) {
  if (l == r) {
    s[i].L.push_back(make_pair(a[l], 1));
    s[i].R.push_back(make_pair(a[r], 1));
    s[i].ret = (a[l] >= X);
    return;
  }
  int mid = (l + r) >> 1;
  build(i << 1, l, mid);
  build(i << 1 | 1, mid + 1, r);
  s[i] = mer(s[i << 1], s[i << 1 | 1]);
}
int main() {
  scanf("%d%d%d", &n, &m, &X);
  for (int i(1); i <= (n); ++i) scanf("%d", a + i);
  build(1, 1, n);
  while (m--) {
    int op, l, r;
    scanf("%d%d%d", &op, &l, &r);
    if (op == 1) {
      a[l] = r;
      update(1, 1, n, l);
    } else {
      printf("%lld\n", query(1, 1, n, l, r).ret);
    }
  }
  return 0;
}
