#include <bits/stdc++.h>
const int maxn = 1e5 + 1;
using namespace std;
const long long MOD = 1e9 + 7;
pair<int, int> suff[20];
pair<int, int> pref[20];
int suff_iter;
int pref_iter;
int suff_val[21];
int x;
int a[maxn];
const int debug = 0;
struct node {
  int dp_first[20];
  int dp_last[20];
  long long dp;
  int lft, rgt;
  void merge(const node &l, const node &r) {
    if (debug) cout << "MERGE" << endl;
    if (debug) cout << "LL" << endl;
    if (debug) cout << endl;
    lft = l.lft;
    rgt = r.rgt;
    for (int i = 0; i < 20; ++i)
      if (l.dp_first[i] == -1)
        dp_first[i] = r.dp_first[i];
      else
        dp_first[i] = l.dp_first[i];
    for (int i = 0; i < 20; ++i) {
      if (r.dp_last[i] == -1)
        dp_last[i] = l.dp_last[i];
      else
        dp_last[i] = r.dp_last[i];
    }
    dp = l.dp + r.dp;
    suff_iter = 0;
    for (int i = 0; i < 20; ++i) {
      if (l.dp_last[i] != -1) suff[suff_iter++] = make_pair(l.dp_last[i], i);
    }
    sort(suff, suff + suff_iter);
    pref_iter = 0;
    for (int i = 0; i < 20; ++i) {
      if (r.dp_first[i] != -1) pref[pref_iter++] = make_pair(r.dp_first[i], i);
    }
    sort(pref, pref + pref_iter);
    suff_val[suff_iter++] = 0;
    for (int i = suff_iter - 2; i >= 0; --i)
      suff_val[i] = suff_val[i + 1] | (1 << (suff[i].second));
    int ptr = 0;
    int pref_val = 0;
    int lst = r.lft;
    for (int i = 0; i < pref_iter;) {
      long long cur = 0;
      while (ptr < suff_iter && (suff_val[ptr] | pref_val) >= x) {
        ++ptr;
      }
      if (ptr == suff_iter) {
        cur = l.rgt - l.lft + 1;
      } else if (ptr != 0) {
        cur = suff[ptr - 1].first - l.lft + 1;
      }
      int pos = pref[i].first;
      if (debug) cout << ptr << endl;
      if (debug)
        cout << i << " " << pos << " " << lst << " " << cur << " " << pref_val
             << endl;
      dp += cur * (pos - lst);
      while (i < pref_iter && pref[i].first == pos) {
        pref_val |= (1 << pref[i].second);
        ++i;
      }
      lst = pos;
    }
    int pos = r.rgt + 1;
    long long cur = 0;
    while (ptr < suff_iter && (suff_val[ptr] | pref_val) >= x) {
      ++ptr;
    }
    if (ptr == suff_iter) {
      cur = l.rgt - l.lft + 1;
    } else if (ptr != 0) {
      cur = suff[ptr - 1].first - l.lft + 1;
    }
    dp += cur * (pos - lst);
    if (debug) cout << "END " << dp << endl;
  }
};
node t[4 * maxn];
void build(int v, int tl, int tr) {
  if (tl == tr - 1) {
    t[v].lft = tl;
    t[v].rgt = tl;
    if (a[tl] >= x)
      t[v].dp = 1;
    else
      t[v].dp = 0;
    for (int i = 0; i < 20; ++i) {
      int cur = -1;
      if (a[tl] & (1 << i)) cur = tl;
      t[v].dp_first[i] = t[v].dp_last[i] = cur;
    }
    return;
  }
  int tm = (tl + tr) >> 1;
  build(v << 1, tl, tm);
  build(v << 1 | 1, tm, tr);
  t[v].merge(t[v << 1], t[v << 1 | 1]);
}
void upd(int v, int tl, int tr, int pos, int val) {
  if (tl == tr - 1) {
    a[tl] = val;
    for (int i = 0; i < 20; ++i) {
      int cur = -1;
      if (val & (1 << i)) cur = tl;
      t[v].dp_last[i] = t[v].dp_first[i] = cur;
    }
    if (val >= x) {
      t[v].dp = 1;
    } else
      t[v].dp = 0;
    return;
  }
  int tm = (tl + tr) >> 1;
  if (tm > pos) {
    upd(v << 1, tl, tm, pos, val);
  } else {
    upd(v << 1 | 1, tm, tr, pos, val);
  }
  t[v].merge(t[v << 1], t[v << 1 | 1]);
}
node get(int v, int tl, int tr, int l, int r) {
  if (tl >= l && tr <= r) {
    return t[v];
  }
  int tm = (tl + tr) >> 1;
  int l1, r1;
  int l2, r2;
  l1 = tl;
  r1 = tm;
  l2 = tm;
  r2 = tr;
  bool left = !(l1 >= r || l >= r1);
  bool right = !(l2 >= r || l >= r2);
  if (left && right) {
    node fi = get(v << 1, l1, r1, l, r);
    node se = get(v << 1 | 1, l2, r2, l, r);
    node res;
    res.merge(fi, se);
    return res;
  } else if (left) {
    return get(v << 1, l1, r1, l, r);
  } else if (right)
    return get(v << 1 | 1, l2, r2, l, r);
  else
    assert(false);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  cin >> x;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  build(1, 1, n + 1);
  while (m--) {
    int tp;
    cin >> tp;
    if (tp == 1) {
      int pos;
      int val;
      cin >> pos >> val;
      upd(1, 1, n + 1, pos, val);
    } else {
      int l, r;
      cin >> l >> r;
      if (debug) cout << "QUERY " << l << " " << r << endl;
      node res = get(1, 1, n + 1, l, r + 1);
      cout << res.dp << "\n";
    }
  }
}
