#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, first, a[N];
struct Node {
  long long ans;
  vector<pair<int, int>> pref, suff;
  Node() : ans(0) {
    pref.assign(1, {0, 0});
    suff.assign(1, {0, 0});
  }
  Node(int val) : ans(val >= first) {
    pref.assign(1, {val, 1});
    suff.assign(1, {val, 1});
  }
  Node(Node L, Node R) {
    ans = L.ans + R.ans;
    pref = L.pref;
    for (auto p : R.pref) {
      int val = p.first, qtd = p.second;
      if ((pref.back().first | val) == pref.back().first) {
        pref[((int)(pref).size()) - 1].second += qtd;
      } else {
        pref.push_back({pref.back().first | val, qtd});
      }
    }
    suff = R.suff;
    for (auto p : L.suff) {
      int val = p.first, qtd = p.second;
      if ((suff.back().first | val) == suff.back().first) {
        suff[((int)(suff).size()) - 1].second += qtd;
      } else {
        suff.push_back({suff.back().first | val, qtd});
      }
    }
    int qtd_right = 0;
    for (int i = 0, j = ((int)(R.pref).size()) - 1; i < ((int)(L.suff).size());
         i++) {
      while (j >= 0 && (L.suff[i].first | R.pref[j].first) >= first) {
        qtd_right += R.pref[j].second;
        j--;
      }
      ans += L.suff[i].second * 1LL * qtd_right;
    }
  }
} node[4 * N];
void build_tree(int idx, int l, int r) {
  if (l == r) {
    node[idx] = Node(a[l]);
  } else {
    int mid = (l + r) / 2;
    build_tree(2 * idx + 1, l, mid);
    build_tree(2 * idx + 2, mid + 1, r);
    node[idx] = Node(node[2 * idx + 1], node[2 * idx + 2]);
  }
}
void modify(int idx, int l, int r, int pos, int val) {
  if (l == r) {
    node[idx] = Node(val);
  } else {
    int mid = (l + r) / 2;
    if (pos <= mid)
      modify(2 * idx + 1, l, mid, pos, val);
    else
      modify(2 * idx + 2, mid + 1, r, pos, val);
    node[idx] = Node(node[2 * idx + 1], node[2 * idx + 2]);
  }
}
Node query(int idx, int l, int r, int a, int b) {
  if (l > b || r < a) return Node();
  if (l >= a && r <= b) return node[idx];
  int mid = (l + r) / 2;
  return Node(query(2 * idx + 1, l, mid, a, b),
              query(2 * idx + 2, mid + 1, r, a, b));
}
int main() {
  scanf("%d %d %d", &n, &m, &first);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  build_tree(0, 1, n);
  while (m--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int i, second;
      scanf("%d %d", &i, &second);
      modify(0, 1, n, i, second);
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      printf("%lld\n", query(0, 1, n, l, r).ans);
    }
  }
  return 0;
}
