#include <bits/stdc++.h>
using namespace std;
const long long MaxN = 100050;
template <class t>
inline void read(t &s) {
  s = 0;
  register long long f = 1;
  register char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  s *= f;
  return;
}
template <class t>
inline void write(t x) {
  if (x < 0) putchar('-'), x = -x;
  long long buf[21], top = 0;
  while (x) buf[++top] = x % 10, x /= 10;
  if (!top) buf[++top] = 0;
  while (top) putchar(buf[top--] ^ '0');
  return;
}
inline void setIn(string s) {
  freopen(s.c_str(), "r", stdin);
  return;
}
inline void setOut(string s) {
  freopen(s.c_str(), "w", stdout);
  return;
}
inline void setIO(string s = "") {
  setIn(s + ".in");
  setOut(s + ".out");
  return;
}
template <class t>
inline bool checkmin(t &x, t y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <class t>
inline bool checkmax(t &x, t y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
inline long long lowbit(long long x) { return x & (-x); }
long long n, q, X;
struct Node {
  long long ans, l, r;
  long long Ln[21], Rn[21], Lp[21], Rp[21], Lcnt, Rcnt;
  inline Node operator+(const Node &nt) const {
    Node res;
    res.ans = ans + nt.ans;
    res.l = l, res.r = nt.r;
    res.Ln[0] = 0, res.Lp[0] = res.l, res.Rn[0] = 0, res.Rp[0] = 0;
    for (long long p1 = Rcnt, p2 = 0; p1; --p1) {
      while ((Rn[p1] | nt.Ln[p2]) < X && p2 < nt.Lcnt) ++p2;
      if ((Rn[p1] | nt.Ln[p2]) >= X)
        res.ans += (nt.r - nt.Lp[p2] + 1) *
                   (Rp[p1] - (p1 == Rcnt ? (l - 1) : Rp[p1 + 1]));
    }
    res.Lcnt = Lcnt, res.Rcnt = nt.Rcnt;
    for (long long i = 1; i <= Lcnt; ++i) res.Ln[i] = Ln[i], res.Lp[i] = Lp[i];
    for (long long i = 1; i <= nt.Rcnt; ++i)
      res.Rn[i] = nt.Rn[i], res.Rp[i] = nt.Rp[i];
    for (long long i = 1; i <= nt.Lcnt; ++i)
      if ((nt.Ln[i] | res.Ln[res.Lcnt]) != res.Ln[res.Lcnt])
        res.Ln[res.Lcnt + 1] = (nt.Ln[i] | res.Ln[res.Lcnt]),
                          res.Lp[res.Lcnt + 1] = nt.Lp[i], ++res.Lcnt;
    for (long long i = 1; i <= Rcnt; ++i)
      if ((Rn[i] | res.Rn[res.Rcnt]) != res.Rn[res.Rcnt])
        res.Rn[res.Rcnt + 1] = (Rn[i] | res.Rn[res.Rcnt]),
                          res.Rp[res.Rcnt + 1] = Rp[i], ++res.Rcnt;
    return res;
  }
} a[MaxN << 2];
inline void Set(long long u, long long k, long long l, long long r) {
  memset(a[u].Ln, 0, sizeof a[u].Ln), memset(a[u].Rn, 0, sizeof a[u].Rn),
      memset(a[u].Lp, 0, sizeof a[u].Lp), memset(a[u].Rp, 0, sizeof a[u].Rp);
  a[u].Ln[0] = 0, a[u].Lp[0] = l, a[u].Rn[0] = 0, a[u].Rp[0] = r + 1;
  a[u].ans = (k >= X), a[u].Lcnt = a[u].Rcnt = 1;
  a[u].Ln[1] = a[u].Rn[1] = k;
  a[u].Lp[1] = a[u].Rp[1] = l;
  a[u].l = l, a[u].r = r;
  return;
}
inline void pushup(long long u) {
  a[u] = a[(u << 1)] + a[(u << 1 | 1)];
  return;
}
inline void buildtr(long long u, long long l, long long r) {
  a[u].l = l, a[u].r = r;
  if (l == r) {
    register long long x;
    read(x);
    Set(u, x, l, r);
    return;
  }
  register long long mid = (l + r) >> 1;
  buildtr((u << 1), l, mid);
  buildtr((u << 1 | 1), mid + 1, r);
  pushup(u);
  return;
}
inline void modify(long long u, long long l, long long r, long long p,
                   long long k) {
  if (l == r) {
    Set(u, k, l, r);
    return;
  }
  register long long mid = (l + r) >> 1;
  p <= mid ? modify((u << 1), l, mid, p, k)
           : modify((u << 1 | 1), mid + 1, r, p, k);
  pushup(u);
  return;
}
inline Node query(long long u, long long l, long long r, long long ql,
                  long long qr) {
  if (ql <= l && r <= qr) return a[u];
  register long long mid = (l + r) >> 1;
  if (ql > mid) return query((u << 1 | 1), mid + 1, r, ql, qr);
  if (mid >= qr) return query((u << 1), l, mid, ql, qr);
  return query((u << 1), l, mid, ql, qr) +
         query((u << 1 | 1), mid + 1, r, ql, qr);
}
signed main(void) {
  read(n), read(q), read(X);
  buildtr(1, 1, n);
  register long long opt, x, y;
  while (q--) {
    read(opt), read(x), read(y);
    if (opt == 1)
      modify(1, 1, n, x, y);
    else
      write(query(1, 1, n, x, y).ans), puts("");
  }
  return 0;
}
