#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, m, K, a[N];
struct data {
  long long ans;
  vector<pair<int, int> > l, r;
  data() {
    l.clear();
    r.clear();
    ans = 0;
  }
  data(int x) {
    l.clear();
    r.clear();
    l.emplace_back(x, 1);
    r.emplace_back(x, 1);
    ans = (x >= K);
  }
  void merge(const vector<pair<int, int> >& a, const vector<pair<int, int> >& b,
             vector<pair<int, int> >& c) const {
    c = a;
    if (c.empty()) c.emplace_back(b[0].first, 0);
    for (auto i : b)
      if ((c.back().first | i.first) == c.back().first)
        c.back().second += i.second;
      else
        c.emplace_back(c.back().first | i.first, i.second);
  }
  data operator+(const data& a) const {
    data b;
    b.ans = ans + a.ans;
    merge(l, a.l, b.l);
    merge(a.r, r, b.r);
    for (int i = 0, j = a.l.size(), tmp = 0; i < (int)r.size(); ++i) {
      for (; j && (r[i].first | a.l[j - 1].first) >= K; tmp += a.l[j].second)
        --j;
      b.ans += (long long)tmp * r[i].second;
    }
    return b;
  }
} S[N * 4], q3;
void bt(int o, int l, int r) {
  if (l == r) {
    S[o] = data(a[l]);
    return;
  }
  int mid = (l + r) / 2;
  bt(o * 2, l, mid);
  bt(o * 2 + 1, mid + 1, r);
  S[o] = S[o * 2] + S[o * 2 + 1];
}
int q1, q2;
void mdf(int o, int l, int r) {
  if (l == r) {
    S[o] = data(q2);
    return;
  }
  int mid = (l + r) / 2;
  if (q1 <= mid)
    mdf(o * 2, l, mid);
  else
    mdf(o * 2 + 1, mid + 1, r);
  S[o] = S[o * 2] + S[o * 2 + 1];
}
void qry(int o, int l, int r) {
  if (q1 <= l && r <= q2) {
    q3 = q3 + S[o];
    return;
  }
  int mid = (l + r) / 2;
  if (q1 <= mid) qry(o * 2, l, mid);
  if (q2 > mid) qry(o * 2 + 1, mid + 1, r);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> K;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  bt(1, 1, n);
  for (; m-- > 0;) {
    int op;
    cin >> op >> q1 >> q2;
    if (op == 1)
      mdf(1, 1, n);
    else {
      q3 = data();
      qry(1, 1, n);
      cout << q3.ans << '\n';
    }
  }
  return 0;
}
