#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void ckmax(T& x, T y) {
  x = (y > x ? y : x);
}
template <typename T>
inline void ckmin(T& x, T y) {
  x = (y < x ? y : x);
}
namespace Fread {
const int SIZE = 1 << 20;
char buf[SIZE], *S, *T;
inline char getchar() {
  if (S == T) {
    T = (S = buf) + fread(buf, 1, SIZE, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
}  // namespace Fread
namespace Fwrite {
const int SIZE = 1 << 20;
char buf[SIZE], *S = buf, *T = buf + SIZE;
inline void flush() {
  fwrite(buf, 1, S - buf, stdout);
  S = buf;
}
inline void putchar(char c) {
  *S++ = c;
  if (S == T) flush();
}
struct _ {
  ~_() { flush(); }
} __;
}  // namespace Fwrite
template <typename T>
inline void read(T& x) {
  x = 0;
  int f = 1;
  char c = Fread::getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = Fread::getchar();
  }
  while (isdigit(c)) x = x * 10 + (c - '0'), c = Fread::getchar();
  x *= f;
}
template <typename T>
inline void write(T x, bool _enter = 0, bool _space = 0) {
  if (!x)
    Fwrite::putchar('0');
  else {
    if (x < 0) Fwrite::putchar('-'), x = -x;
    static char dig[41];
    int top = 0;
    while (x) dig[++top] = (x % 10) + '0', x /= 10;
    while (top) Fwrite::putchar(dig[top--]);
  }
  if (_enter) Fwrite::putchar('\n');
  if (_space) Fwrite::putchar(' ');
}
namespace Fastio {
struct reader {
  template <typename T>
  reader& operator>>(T& x) {
    ::read(x);
    return *this;
  }
  reader& operator>>(char& c) {
    c = Fread::getchar();
    while (c == '\n' || c == ' ') c = Fread::getchar();
    return *this;
  }
  reader& operator>>(char* str) {
    int len = 0;
    char c = Fread::getchar();
    while (c == '\n' || c == ' ') c = Fread::getchar();
    while (c != '\n' && c != ' ') str[len++] = c, c = Fread::getchar();
    str[len] = '\0';
    return *this;
  }
} cin;
const char endl = '\n';
struct writer {
  template <typename T>
  writer& operator<<(T x) {
    ::write(x, 0, 0);
    return *this;
  }
  writer& operator<<(char c) {
    Fwrite::putchar(c);
    return *this;
  }
  writer& operator<<(const char* str) {
    int cur = 0;
    while (str[cur]) Fwrite::putchar(str[cur++]);
    return *this;
  }
} cout;
}  // namespace Fastio
const int MAXN = 1e5;
int n, m, X, a[MAXN + 5];
struct SegmentTree {
  int tl[MAXN * 4 + 5], tr[MAXN * 4 + 5];
  long long ans[MAXN * 4 + 5];
  vector<pair<int, int> > pre[MAXN * 4 + 5], suf[MAXN * 4 + 5];
  void ck(int p) {
    assert(((int)(pre[p]).size()) && pre[p][0].first == tl[p]);
    assert(((int)(suf[p]).size()) && suf[p][0].first == tr[p]);
  }
  void push_up(int p) {
    int ls = p << 1, rs = p << 1 | 1;
    ck(ls);
    ck(rs);
    ans[p] = ans[ls] + ans[rs];
    for (int i = 0, j = ((int)(suf[ls]).size()); i < ((int)(pre[rs]).size());
         ++i) {
      int nxt =
          (i <= ((int)(pre[rs]).size()) - 2 ? pre[rs][i + 1].first : tr[p] + 1);
      while (j > 0 && (suf[ls][j - 1].second | pre[rs][i].second) >= X) --j;
      if (j != ((int)(suf[ls]).size()))
        ans[p] += (long long)(suf[ls][j].first - tl[p] + 1) *
                  (nxt - pre[rs][i].first);
    }
    pre[p] = pre[ls];
    for (int i = 0; i < ((int)(pre[rs]).size()); ++i) {
      if (pre[p].back().second != (pre[p].back().second | pre[rs][i].second)) {
        pre[p].push_back(make_pair(pre[rs][i].first,
                                   pre[p].back().second | pre[rs][i].second));
      }
    }
    suf[p] = suf[rs];
    for (int i = 0; i < ((int)(suf[ls]).size()); ++i) {
      if (suf[p].back().second != (suf[p].back().second | suf[ls][i].second)) {
        suf[p].push_back(make_pair(suf[ls][i].first,
                                   suf[p].back().second | suf[ls][i].second));
      }
    }
    assert(((int)(pre[p]).size()) <= 21);
    assert(((int)(suf[p]).size()) <= 21);
  }
  void build(int p, int l, int r) {
    tl[p] = l;
    tr[p] = r;
    if (l == r) {
      ans[p] = (a[l] >= X);
      pre[p].push_back(make_pair(l, a[l]));
      suf[p].push_back(make_pair(l, a[l]));
      return;
    }
    int mid = (l + r) >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
    push_up(p);
  }
  void point_modify(int p, int l, int r, int pos, int v) {
    if (l == r) {
      ans[p] = (v >= X);
      pre[p][0] = make_pair(l, v);
      suf[p][0] = make_pair(l, v);
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid)
      point_modify(p << 1, l, mid, pos, v);
    else
      point_modify(p << 1 | 1, mid + 1, r, pos, v);
    push_up(p);
  }
  long long query(int p, int l, int r, int ql, int qr) {
    assert(ql >= l);
    assert(qr <= r);
    if (ql == l && qr == r) return ans[p];
    int mid = (l + r) >> 1;
    if (qr <= mid)
      return query(p << 1, l, mid, ql, qr);
    else if (ql > mid)
      return query(p << 1 | 1, mid + 1, r, ql, qr);
    else {
      long long res = query(p << 1, l, mid, ql, mid) +
                      query(p << 1 | 1, mid + 1, r, mid + 1, qr);
      int ls = p << 1, rs = p << 1 | 1;
      ck(ls);
      ck(rs);
      int j = ((int)(suf[ls]).size()) - 1;
      while (suf[ls][j].first < ql) --j;
      assert(j >= 0);
      for (int i = 0; i < ((int)(pre[rs]).size()) && pre[rs][i].first <= qr;
           ++i) {
        int nxt = (i <= ((int)(pre[rs]).size()) - 2 ? pre[rs][i + 1].first
                                                    : tr[p] + 1);
        ckmin(nxt, qr + 1);
        if ((suf[ls][j].second | pre[rs][i].second) < X) continue;
        while (j > 0 && (suf[ls][j - 1].second | pre[rs][i].second) >= X) --j;
        res +=
            (long long)(suf[ls][j].first - ql + 1) * (nxt - pre[rs][i].first);
      }
      return res;
    }
  }
  SegmentTree() {}
} T;
int main() {
  Fastio::cin >> n >> m >> X;
  for (int i = 1; i <= n; ++i) Fastio::cin >> a[i];
  T.build(1, 1, n);
  while (m--) {
    int op;
    Fastio::cin >> op;
    if (op == 1) {
      int i, y;
      Fastio::cin >> i >> y;
      T.point_modify(1, 1, n, i, y);
    } else {
      int l, r;
      Fastio::cin >> l >> r;
      Fastio::cout << T.query(1, 1, n, l, r) << Fastio::endl;
    }
  }
  return 0;
}
