#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 998244353) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
const int MN = 100005 * 4;
int X, a[100005];
struct nd {
  long long ans;
  int mx;
  pair<int, int> mpl[25], mpr[25];
  int sl, sr;
  nd() {
    ans = 0;
    mx = 0;
    sl = 0;
    sr = 0;
  }
  void init(int val) {
    mpl[1] = {val, 1};
    mpr[1] = {val, 1};
    ans = X <= val;
    mx = val;
    sl = sr = 1;
  }
  friend nd operator+(const nd &x, const nd &y) {
    nd z = nd();
    z.ans = x.ans + y.ans;
    z.mx = x.mx | y.mx;
    int j = y.sl, sum = 0;
    for (int(i) = 1; (i) <= (int)(x.sr); (i)++) {
      while (j >= 0 && (x.mpr[i].first | y.mpl[j].first) >= X)
        sum += y.mpl[j--].second;
      z.ans += (long long)sum * x.mpr[i].second;
    }
    for (int(i) = 1; (i) <= (int)(x.sl); (i)++) z.mpl[++z.sl] = x.mpl[i];
    for (int(i) = 1; (i) <= (int)(y.sl); (i)++) {
      int tar = y.mpl[i].first | z.mpl[z.sl].first;
      int cnt = y.mpl[i].second;
      if (tar == z.mpl[z.sl].first)
        z.mpl[z.sl].second += cnt;
      else
        z.mpl[++z.sl] = {tar, cnt};
    }
    for (int(i) = 1; (i) <= (int)(y.sr); (i)++) z.mpr[++z.sr] = y.mpr[i];
    for (int(i) = 1; (i) <= (int)(x.sr); (i)++) {
      int tar = x.mpr[i].first | z.mpr[z.sr].first;
      int cnt = x.mpr[i].second;
      if (tar == z.mpr[z.sr].first)
        z.mpr[z.sr].second += cnt;
      else
        z.mpr[++z.sr] = {tar, cnt};
    }
    return z;
  }
};
nd T[MN];
void Up(int rt, int l, int r) { T[rt] = T[(rt << 1)] + T[(rt << 1 | 1)]; }
void build(int rt, int l, int r) {
  if (l + 1 == r) {
    T[rt].init(a[r]);
    return;
  }
  int mid = (l + r) / 2;
  build((rt << 1), l, mid);
  build((rt << 1 | 1), mid, r);
  Up(rt, l, r);
}
void upt(int rt, int l, int r, int pos, int val) {
  if (pos <= l || r < pos) return;
  if (l + 1 == r) {
    T[rt].init(val);
    return;
  }
  int mid = (l + r) / 2;
  upt((rt << 1), l, mid, pos, val);
  upt((rt << 1 | 1), mid, r, pos, val);
  Up(rt, l, r);
}
nd qy(int rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return T[rt];
  }
  int mid = (l + r) / 2;
  if (R <= mid)
    return qy((rt << 1), l, mid, L, R);
  else if (mid <= L)
    return qy((rt << 1 | 1), mid, r, L, R);
  return qy((rt << 1), l, mid, L, R) + qy((rt << 1 | 1), mid, r, L, R);
}
void fmain(int ID) {
  scanf("%d%d%d", &n, &m, &X);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", a + i);
  build(1, 0, n);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      upt(1, 0, n, x, y);
    } else {
      printf("%lld\n", qy(1, 0, n, x - 1, y).ans);
    }
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
