#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long mod = 1e9 + 7;
const int M = 5e5;
const int siz = 1000;
inline void rd(long long &x) {
  x = 0;
  char ch = getchar();
  bool flag = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') flag = 1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10ll + ch - '0', ch = getchar();
  if (flag) x = -x;
  return;
}
inline void rd(int &x) {
  x = 0;
  char ch = getchar();
  bool flag = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') flag = 1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  if (flag) x = -x;
  return;
}
inline char rch() {
  char c;
  while ((c = getchar()) != 'N' && c != 'E')
    ;
  return c;
}
int n, m, a[N], X;
struct SpringWait {
  int val, siz;
};
long long ans[N << 2];
vector<SpringWait> pre[N << 2], suf[N << 2];
struct node {
  long long ans;
  vector<SpringWait> pre, suf;
  node() {
    ans = 0;
    pre.clear();
    suf.clear();
  };
} t[N << 2];
inline node pushup(node x, node y) {
  node z;
  z.ans = x.ans + y.ans;
  long long sum = 0;
  for (int i = 0, j = y.pre.size() - 1; i < x.suf.size(); ++i) {
    while (j >= 0 && (y.pre[j].val | x.suf[i].val) >= X) {
      sum += y.pre[j].siz;
      --j;
    }
    z.ans = z.ans + 1ll * sum * x.suf[i].siz;
  }
  z.pre = x.pre;
  for (int i = 0; i < y.pre.size(); ++i) {
    int sz = z.pre.size() - 1;
    if (z.pre.size() == 0) {
      z.pre.push_back(y.pre[i]);
    } else if ((z.pre[sz].val | y.pre[i].val) != z.pre[sz].val) {
      z.pre.push_back(
          (SpringWait){(z.pre[sz].val | y.pre[i].val), y.pre[i].siz});
    } else {
      z.pre[sz].siz += y.pre[i].siz;
    }
  }
  z.suf = y.suf;
  for (int i = 0; i < x.suf.size(); ++i) {
    int sz = z.suf.size() - 1;
    if (z.suf.size() == 0) {
      z.suf.push_back(x.suf[i]);
    } else if ((z.suf[sz].val | x.suf[i].val) != z.suf[sz].val) {
      z.suf.push_back(
          (SpringWait){(z.suf[sz].val | x.suf[i].val), x.suf[i].siz});
    } else {
      z.suf[sz].siz += x.suf[i].siz;
    }
  }
  return z;
}
inline void built(int k, int l, int r) {
  if (l == r) {
    if (a[l] >= X) t[k].ans = 1;
    t[k].pre.push_back((SpringWait){a[l], 1});
    t[k].suf.push_back((SpringWait){a[l], 1});
  } else {
    int mid = (l + r) >> 1;
    built(k << 1, l, mid);
    built(k << 1 | 1, mid + 1, r);
    t[k] = pushup(t[k << 1], t[k << 1 | 1]);
  }
}
inline void update(int k, int l, int r, int x, int y) {
  if (l == r) {
    a[x] = y;
    if (a[l] >= X)
      t[k].ans = 1;
    else
      t[k].ans = 0;
    t[k].pre.clear();
    t[k].suf.clear();
    t[k].pre.push_back((SpringWait){a[l], 1});
    t[k].suf.push_back((SpringWait){a[l], 1});
  } else {
    int mid = (l + r) >> 1;
    if (x <= mid)
      update(k << 1, l, mid, x, y);
    else
      update(k << 1 | 1, mid + 1, r, x, y);
    t[k] = pushup(t[k << 1], t[k << 1 | 1]);
  }
}
inline node query(int k, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return t[k];
  } else {
    int mid = (l + r) >> 1;
    if (L <= mid && mid < R)
      return pushup(query(k << 1, l, mid, L, R),
                    query(k << 1 | 1, mid + 1, r, L, R));
    else if (L <= mid)
      return query(k << 1, l, mid, L, R);
    else
      return query(k << 1 | 1, mid + 1, r, L, R);
  }
}
int main() {
  rd(n);
  rd(m);
  rd(X);
  for (int i = 1; i <= n; ++i) rd(a[i]);
  built(1, 1, n);
  for (int i = 1, op, x, y; i <= m; ++i) {
    rd(op);
    rd(x);
    rd(y);
    if (op == 1) {
      update(1, 1, n, x, y);
    } else {
      node ans = query(1, 1, n, x, y);
      printf("%lld\n", ans.ans);
    }
  }
  return 0;
}
