#include <bits/stdc++.h>
using namespace std;
struct node {
  long long cnt;
  vector<pair<long long, long long> > st, ed;
} t[400005];
long long n, m, x, a[200005];
node merge(node a, node b) {
  if (!a.ed.size()) return b;
  if (!b.ed.size()) return a;
  node ret;
  long long tot = 0, tmp;
  ret.cnt = a.cnt + b.cnt;
  vector<pair<long long, long long> >::iterator i, j;
  for (i = a.ed.begin(); i != a.ed.end(); i++) {
    for (j = b.st.begin(); j != b.st.end(); j++) {
      if (((*i).first | (*j).first) >= x) {
        tot += 1ll * (*i).second * (*j).second;
      }
    }
  }
  ret.cnt += tot;
  ret.st = a.st;
  tmp = ret.st.back().first;
  for (i = b.st.begin(); i != b.st.end(); i++) {
    if (((*i).first | tmp) == tmp) {
      ret.st.back().second += (*i).second;
    } else {
      ret.st.push_back({(*i).first | tmp, (*i).second});
      tmp |= (*i).first;
    }
  }
  ret.ed = b.ed;
  tmp = ret.ed.back().first;
  for (i = a.ed.begin(); i != a.ed.end(); i++) {
    if (((*i).first | tmp) == tmp) {
      ret.ed.back().second += (*i).second;
    } else {
      ret.ed.push_back({(*i).first | tmp, (*i).second});
      tmp |= (*i).first;
    }
  }
  return ret;
}
void pushup(long long x) { t[x] = merge(t[x * 2], t[x * 2 + 1]); }
void build(long long now, long long l, long long r) {
  if (l == r) {
    t[now].ed.push_back({a[l], 1});
    t[now].st.push_back({a[l], 1});
    if (a[l] >= x) {
      t[now].cnt = 1;
    } else
      t[now].cnt = 0;
    return;
  }
  long long mid = (l + r) / 2;
  build(now * 2, l, mid);
  build(now * 2 + 1, mid + 1, r);
  pushup(now);
}
void modify(long long now, long long l, long long r, long long y, long long z) {
  if (l == r) {
    a[y] = z;
    t[now].st.clear();
    t[now].ed.clear();
    t[now].st.push_back({z, 1});
    t[now].ed.push_back({z, 1});
    if (a[l] >= x) {
      t[now].cnt = 1;
    } else
      t[now].cnt = 0;
    return;
  }
  long long mid = (l + r) / 2;
  if (y <= mid) {
    modify(now * 2, l, mid, y, z);
  } else
    modify(now * 2 + 1, mid + 1, r, y, z);
  pushup(now);
}
node query(long long now, long long l, long long r, long long L, long long R) {
  if (L <= l && r <= R) return t[now];
  node ret;
  long long mid = (l + r) / 2;
  if (L <= mid) ret = merge(ret, query(now * 2, l, mid, L, R));
  if (R > mid) ret = merge(ret, query(now * 2 + 1, mid + 1, r, L, R));
  return ret;
}
int main() {
  long long i, p, l, r;
  cin >> n >> m >> x;
  for (i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, n);
  for (i = 1; i <= m; i++) {
    cin >> p >> l >> r;
    if (p == 1) {
      a[l] = r;
      modify(1, 1, n, l, r);
    } else {
      cout << query(1, 1, n, l, r).cnt << endl;
    }
  }
  return 0;
}
