#include <bits/stdc++.h>
using namespace std;
long long X, n, q;
struct node {
  vector<long long> pre, suf;
  long long cnt;
  node() : cnt(0) {}
};
vector<node> s;
vector<long long> a;
void unite(node& ans, node& left, node& right) {
  ans.cnt = left.cnt + right.cnt;
  long long v = 0, LS = left.suf.size(), RP = right.pre.size();
  ans.suf = right.suf;
  for (long long i : ans.suf) v |= a[i];
  for (long long j = 0; j < LS; j++) {
    long long i = left.suf[j];
    if ((v | a[i]) != v || j == LS - 1) {
      ans.suf.push_back(i);
      v |= a[i];
    }
  }
  ans.pre = left.pre;
  v = 0;
  for (long long i : ans.pre) v |= a[i];
  for (long long j = 0; j < RP; j++) {
    long long i = right.pre[j];
    if ((v | a[i]) != v || j == RP - 1) {
      ans.pre.push_back(i);
      v |= a[i];
    }
  }
  long long init = 0;
  for (long long i = 0; i < LS; i++) {
    init |= a[left.suf[i]];
    v = init;
    long long j = 0;
    v |= a[right.pre[0]];
    while (v < X) {
      j++;
      if (j < RP) {
        v |= a[right.pre[j]];
      } else {
        break;
      }
    }
    if (j == RP) continue;
    long long lf;
    if (i == LS - 1)
      lf = 1;
    else
      lf = left.suf[i] - left.suf[i + 1];
    ans.cnt += lf * (right.pre.back() - right.pre[j] + 1);
  }
}
void build(long long x, long long lx, long long rx) {
  if (lx == rx) {
    s[x].suf = {lx};
    s[x].pre = {lx};
    if (a[lx] >= X) {
      s[x].cnt = 1;
    } else {
      s[x].cnt = 0;
    }
    return;
  }
  build(2 * x, lx, (lx + rx) / 2);
  build(2 * x | 1, (lx + rx) / 2 + 1, rx);
  unite(s[x], s[2 * x], s[2 * x | 1]);
}
void update(long long x, long long lx, long long rx, long long i) {
  if (lx == rx) {
    s[x].suf = {lx};
    s[x].pre = {lx};
    if (a[lx] >= X)
      s[x].cnt = 1;
    else
      s[x].cnt = 0;
    return;
  }
  if (i <= (lx + rx) / 2)
    update(2 * x, lx, (lx + rx) / 2, i);
  else
    update(2 * x | 1, (lx + rx) / 2 + 1, rx, i);
  unite(s[x], s[2 * x], s[2 * x | 1]);
}
void calc(long long x, long long lx, long long rx, long long l, long long r,
          vector<node>& ans) {
  if (lx == l && rx == r) {
    ans.push_back(s[x]);
    return;
  }
  if (l <= (lx + rx) / 2) {
    calc(2 * x, lx, (lx + rx) / 2, l, min(r, (lx + rx) / 2), ans);
  }
  if (r > (lx + rx) / 2) {
    calc(2 * x | 1, (lx + rx) / 2 + 1, rx, max(l, (lx + rx) / 2 + 1), r, ans);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> X;
  a.resize(n);
  for (long long& i : a) cin >> i;
  s.resize(4 * n);
  build(1, 0, n - 1);
  while (q--) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long i, v;
      cin >> i >> v;
      --i;
      a[i] = v;
      update(1, 0, n - 1, i);
    } else {
      long long l, r;
      cin >> l >> r;
      --l, --r;
      vector<node> ali;
      calc(1, 0, n - 1, l, r, ali);
      node ans = ali[0];
      for (long long i = 1; i < ali.size(); i++) {
        node tmp;
        unite(tmp, ans, ali[i]);
        ans = tmp;
      }
      cout << ans.cnt << "\n";
    }
  }
}

### Prompt

Please create a solution in Cpp to the following problem:

Sonya has an array a_1, a_2, …, a_n consisting of n integers and also one non-negative integer x. She has to perform m queries of two types:

  * 1 i y: replace i-th element by value y, i.e. to perform an operation a_{i} := y; 
  * 2 l r: find the number of pairs (L, R) that l≤ L≤ R≤ r and bitwise OR of all integers in the range [L, R] is at least x (note that x is a constant for all queries). 



Can you help Sonya perform all her queries?

Bitwise OR is a binary operation on a pair of non-negative integers. To calculate the bitwise OR of two numbers, you need to write both numbers in binary notation. The result is a number, in binary, which contains a one in each digit if there is a one in the binary notation of at least one of the two numbers. For example, 10 OR 19 = 1010_2 OR 10011_2 = 11011_2 = 27.

Input

The first line contains three integers n, m, and x (1≤ n, m≤ 10^5, 0≤ x<2^{20}) — the number of numbers, the number of queries, and the constant for all queries.

The second line contains n integers a_1, a_2, …, a_n (0≤ a_i<2^{20}) — numbers of the array.

The following m lines each describe an query. A line has one of the following formats:

  * 1 i y (1≤ i≤ n, 0≤ y<2^{20}), meaning that you have to replace a_{i} by y; 
  * 2 l r (1≤ l≤ r≤ n), meaning that you have to find the number of subarrays on the segment from l to r that the bitwise OR of all numbers there is at least x. 

Output

For each query of type 2, print the number of subarrays such that the bitwise OR of all the numbers in the range is at least x.

Examples

Input

4 8 7
0 3 6 1
2 1 4
2 3 4
1 1 7
2 1 4
2 1 3
2 1 1
1 3 0
2 1 4


Output

5
1
7
4
1
4


Input

5 5 7
6 0 3 15 2
2 1 5
1 4 4
2 1 5
2 3 5
2 1 4


Output

9
7
2
4

Note

In the first example, there are an array [0, 3, 6, 1] and queries: 

  1. on the segment [1…4], you can choose pairs (1, 3), (1, 4), (2, 3), (2, 4), and (3, 4); 
  2. on the segment [3…4], you can choose pair (3, 4); 
  3. the first number is being replacing by 7, after this operation, the array will consist of [7, 3, 6, 1]; 
  4. on the segment [1…4], you can choose pairs (1, 1), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), and (3, 4); 
  5. on the segment [1…3], you can choose pairs (1, 1), (1, 2), (1, 3), and (2, 3); 
  6. on the segment [1…1], you can choose pair (1, 1); 
  7. the third number is being replacing by 0, after this operation, the array will consist of [7, 3, 0, 1]; 
  8. on the segment [1…4], you can choose pairs (1, 1), (1, 2), (1, 3), and (1, 4). 



In the second example, there are an array [6, 0, 3, 15, 2] are queries: 

  1. on the segment [1…5], you can choose pairs (1, 3), (1, 4), (1, 5), (2, 4), (2, 5), (3, 4), (3, 5), (4, 4), and (4, 5); 
  2. the fourth number is being replacing by 4, after this operation, the array will consist of [6, 0, 3, 4, 2]; 
  3. on the segment [1…5], you can choose pairs (1, 3), (1, 4), (1, 5), (2, 4), (2, 5), (3, 4), and (3, 5); 
  4. on the segment [3…5], you can choose pairs (3, 4) and (3, 5); 
  5. on the segment [1…4], you can choose pairs (1, 3), (1, 4), (2, 4), and (3, 4). 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long X, n, q;
struct node {
  vector<long long> pre, suf;
  long long cnt;
  node() : cnt(0) {}
};
vector<node> s;
vector<long long> a;
void unite(node& ans, node& left, node& right) {
  ans.cnt = left.cnt + right.cnt;
  long long v = 0, LS = left.suf.size(), RP = right.pre.size();
  ans.suf = right.suf;
  for (long long i : ans.suf) v |= a[i];
  for (long long j = 0; j < LS; j++) {
    long long i = left.suf[j];
    if ((v | a[i]) != v || j == LS - 1) {
      ans.suf.push_back(i);
      v |= a[i];
    }
  }
  ans.pre = left.pre;
  v = 0;
  for (long long i : ans.pre) v |= a[i];
  for (long long j = 0; j < RP; j++) {
    long long i = right.pre[j];
    if ((v | a[i]) != v || j == RP - 1) {
      ans.pre.push_back(i);
      v |= a[i];
    }
  }
  long long init = 0;
  for (long long i = 0; i < LS; i++) {
    init |= a[left.suf[i]];
    v = init;
    long long j = 0;
    v |= a[right.pre[0]];
    while (v < X) {
      j++;
      if (j < RP) {
        v |= a[right.pre[j]];
      } else {
        break;
      }
    }
    if (j == RP) continue;
    long long lf;
    if (i == LS - 1)
      lf = 1;
    else
      lf = left.suf[i] - left.suf[i + 1];
    ans.cnt += lf * (right.pre.back() - right.pre[j] + 1);
  }
}
void build(long long x, long long lx, long long rx) {
  if (lx == rx) {
    s[x].suf = {lx};
    s[x].pre = {lx};
    if (a[lx] >= X) {
      s[x].cnt = 1;
    } else {
      s[x].cnt = 0;
    }
    return;
  }
  build(2 * x, lx, (lx + rx) / 2);
  build(2 * x | 1, (lx + rx) / 2 + 1, rx);
  unite(s[x], s[2 * x], s[2 * x | 1]);
}
void update(long long x, long long lx, long long rx, long long i) {
  if (lx == rx) {
    s[x].suf = {lx};
    s[x].pre = {lx};
    if (a[lx] >= X)
      s[x].cnt = 1;
    else
      s[x].cnt = 0;
    return;
  }
  if (i <= (lx + rx) / 2)
    update(2 * x, lx, (lx + rx) / 2, i);
  else
    update(2 * x | 1, (lx + rx) / 2 + 1, rx, i);
  unite(s[x], s[2 * x], s[2 * x | 1]);
}
void calc(long long x, long long lx, long long rx, long long l, long long r,
          vector<node>& ans) {
  if (lx == l && rx == r) {
    ans.push_back(s[x]);
    return;
  }
  if (l <= (lx + rx) / 2) {
    calc(2 * x, lx, (lx + rx) / 2, l, min(r, (lx + rx) / 2), ans);
  }
  if (r > (lx + rx) / 2) {
    calc(2 * x | 1, (lx + rx) / 2 + 1, rx, max(l, (lx + rx) / 2 + 1), r, ans);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> X;
  a.resize(n);
  for (long long& i : a) cin >> i;
  s.resize(4 * n);
  build(1, 0, n - 1);
  while (q--) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long i, v;
      cin >> i >> v;
      --i;
      a[i] = v;
      update(1, 0, n - 1, i);
    } else {
      long long l, r;
      cin >> l >> r;
      --l, --r;
      vector<node> ali;
      calc(1, 0, n - 1, l, r, ali);
      node ans = ali[0];
      for (long long i = 1; i < ali.size(); i++) {
        node tmp;
        unite(tmp, ans, ali[i]);
        ans = tmp;
      }
      cout << ans.cnt << "\n";
    }
  }
}

```