#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, a[N], K, Q, u, v;
struct ky {
  vector<pair<int, int> > pre, suf;
  long long ans;
  ky() {}
  ky(const int x) {
    pre.clear(), suf.clear(), pre.push_back(make_pair(x, 1)),
        suf.push_back(make_pair(x, 1)), ans = (x >= K);
  }
  inline void mer(const vector<pair<int, int> > a,
                  const vector<pair<int, int> > b,
                  register vector<pair<int, int> >& c) const {
    c = a, c.empty() ? c.push_back(make_pair(b[0].first, 0)), 0 : 0;
    for (const auto& i : b)
      ((c.back().first | i.first) ^ c.back().first)
          ? c.push_back(make_pair(c.back().first | i.first, i.second)),
          0 : c.back().second += i.second;
  }
  ky operator+(const ky& b) const {
    register ky c;
    c.ans = ans + b.ans;
    mer(pre, b.pre, c.pre), mer(b.suf, suf, c.suf);
    for (register int i = 0, j = b.pre.size(), tmp = 0; i < suf.size(); ++i) {
      while (j && ((suf[i].first | b.pre[j - 1].first) >= K))
        --j, tmp += b.pre[j].second;
      c.ans += (0ll + tmp) * suf[i].second;
    }
    return c;
  }
} s[N], ans;
inline void B(const int rt, const int l, const int r) {
  if (l == r) return s[rt] = ky(a[l]), void();
  const int mid = l + r >> 1, ls = rt << 1, rs = ls | 1;
  B(ls, l, mid), B(rs, mid + 1, r), s[rt] = s[ls] + s[rs];
}
inline void upd(const int rt, const int l, const int r, const int pos,
                const int x) {
  if (l == r) return s[rt] = ky(x), void();
  const int mid = l + r >> 1, ls = rt << 1, rs = ls | 1;
  pos <= mid ? upd(ls, l, mid, pos, x) : upd(rs, mid + 1, r, pos, x),
      s[rt] = s[ls] + s[rs];
}
inline ky que(const int rt, const int l, const int r, const int u,
              const int v) {
  if (l >= u && r <= v) return s[rt];
  const int mid = l + r >> 1, ls = rt << 1, rs = ls | 1;
  if (v <= mid) return que(ls, l, mid, u, v);
  if (u > mid) return que(rs, mid + 1, r, u, v);
  return que(ls, l, mid, u, mid) + que(rs, mid + 1, r, mid + 1, v);
}
int main() {
  scanf("%d%d%d", &n, &Q, &K);
  register int i;
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  B(1, 1, n);
  while (Q--)
    scanf("%d%d%d", &i, &u, &v), i ^ 1 ? ans = que(1, 1, n, u, v),
                                         printf("%lld\n", ans.ans),
                                         void() : upd(1, 1, n, u, v);
  return 0;
}
