#include <bits/stdc++.h>
using namespace std;
const int maxn = 50010, maxV = maxn * 100;
int n, m, tot, ch[maxV][2], tag[maxV];
bool mark[maxV];
long long U, a[maxn], b[maxn];
char op[maxn][10];
vector<pair<int, int>> E[maxn];
void pushdown(int k) {
  if (!ch[k][0]) ch[k][0] = ++tot;
  if (!ch[k][1]) ch[k][1] = ++tot;
  if (tag[k]) tag[ch[k][0]] = tag[ch[k][1]] = tag[k], tag[k] = 0;
}
void cov(int k, long long l, long long r, long long ql, long long qr, int v) {
  if (l >= ql && r <= qr) {
    tag[k] = v;
    return;
  }
  pushdown(k);
  if (((l + r) >> 1) >= ql) cov(ch[k][0], l, ((l + r) >> 1), ql, qr, v);
  if (((l + r) >> 1) < qr) cov(ch[k][1], ((l + r) >> 1) + 1, r, ql, qr, v);
}
void dfs(int k) {
  if (!ch[k][0] && !ch[k][1]) {
    mark[k] = 1;
    return;
  }
  pushdown(k), dfs(ch[k][0]), dfs(ch[k][1]);
}
void merge(int k1, int k2) {
  if (mark[k1] && mark[k2]) {
    E[min(tag[k1], tag[k2])].emplace_back(k1, k2);
    return;
  }
  if (mark[k1])
    merge(k1, ch[k2][0]), merge(k1, ch[k2][1]);
  else if (mark[k2])
    merge(ch[k1][0], k2), merge(ch[k1][1], k2);
  else
    merge(ch[k1][0], ch[k2][0]), merge(ch[k1][1], ch[k2][1]);
}
int get(int k, long long l, long long r, long long p) {
  if (mark[k]) return k;
  return ((l + r) >> 1) >= p ? get(ch[k][0], l, ((l + r) >> 1), p)
                             : get(ch[k][1], ((l + r) >> 1) + 1, r, p);
}
namespace DSU {
int fa[maxV];
void init() { iota(fa + 1, fa + tot + 1, 1); }
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void unite(int x, int y) { fa[find(x)] = find(y); }
bool test(int x, int y) { return find(x) == find(y); }
}  // namespace DSU
int main() {
  scanf("%d %d", &n, &m), U = (1LL << n) - 1;
  tag[++tot] = m + 1;
  for (int i = 1; i <= m; i++) {
    scanf("%s %lld %lld", op[i], &a[i], &b[i]);
    if (op[i][0] == 'b') cov(1, 0, U, a[i], b[i], i);
  }
  dfs(1);
  for (int i = 1; i <= tot; i++) {
    if (!mark[i]) merge(ch[i][0], ch[i][1]);
  }
  DSU::init();
  for (auto &e : E[m + 1]) {
    DSU::unite(e.first, e.second);
  }
  vector<int> ans;
  for (int i = m; i; i--) {
    if (op[i][0] == 'b') {
      for (auto &e : E[i]) DSU::unite(e.first, e.second);
    } else {
      ans.push_back(DSU::test(get(1, 0, U, a[i]), get(1, 0, U, b[i])));
    }
  }
  reverse(ans.begin(), ans.end());
  for (int x : ans) printf("%d\n", x);
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

<image>

As mentioned previously William really likes playing video games. In one of his favorite games, the player character is in a universe where every planet is designated by a binary number from 0 to 2^n - 1. On each planet, there are gates that allow the player to move from planet i to planet j if the binary representations of i and j differ in exactly one bit.

William wants to test you and see how you can handle processing the following queries in this game universe:

  * Destroy planets with numbers from l to r inclusively. These planets cannot be moved to anymore.
  * Figure out if it is possible to reach planet b from planet a using some number of planetary gates. It is guaranteed that the planets a and b are not destroyed. 

Input

The first line contains two integers n, m (1 ≤ n ≤ 50, 1 ≤ m ≤ 5 ⋅ 10^4), which are the number of bits in binary representation of each planets' designation and the number of queries, respectively.

Each of the next m lines contains a query of two types:

block l r — query for destruction of planets with numbers from l to r inclusively (0 ≤ l ≤ r < 2^n). It's guaranteed that no planet will be destroyed twice.

ask a b — query for reachability between planets a and b (0 ≤ a, b < 2^n). It's guaranteed that planets a and b hasn't been destroyed yet.

Output

For each query of type ask you must output "1" in a new line, if it is possible to reach planet b from planet a and "0" otherwise (without quotation marks).

Examples

Input


3 3
ask 0 7
block 3 6
ask 0 7


Output


1
0


Input


6 10
block 12 26
ask 44 63
block 32 46
ask 1 54
block 27 30
ask 10 31
ask 11 31
ask 49 31
block 31 31
ask 2 51


Output


1
1
0
0
1
0

Note

The first example test can be visualized in the following way:

<image>

Response to a query ask 0 7 is positive.

Next after query block 3 6 the graph will look the following way (destroyed vertices are highlighted):

<image>

Response to a query ask 0 7 is negative, since any path from vertex 0 to vertex 7 must go through one of the destroyed vertices.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 50010, maxV = maxn * 100;
int n, m, tot, ch[maxV][2], tag[maxV];
bool mark[maxV];
long long U, a[maxn], b[maxn];
char op[maxn][10];
vector<pair<int, int>> E[maxn];
void pushdown(int k) {
  if (!ch[k][0]) ch[k][0] = ++tot;
  if (!ch[k][1]) ch[k][1] = ++tot;
  if (tag[k]) tag[ch[k][0]] = tag[ch[k][1]] = tag[k], tag[k] = 0;
}
void cov(int k, long long l, long long r, long long ql, long long qr, int v) {
  if (l >= ql && r <= qr) {
    tag[k] = v;
    return;
  }
  pushdown(k);
  if (((l + r) >> 1) >= ql) cov(ch[k][0], l, ((l + r) >> 1), ql, qr, v);
  if (((l + r) >> 1) < qr) cov(ch[k][1], ((l + r) >> 1) + 1, r, ql, qr, v);
}
void dfs(int k) {
  if (!ch[k][0] && !ch[k][1]) {
    mark[k] = 1;
    return;
  }
  pushdown(k), dfs(ch[k][0]), dfs(ch[k][1]);
}
void merge(int k1, int k2) {
  if (mark[k1] && mark[k2]) {
    E[min(tag[k1], tag[k2])].emplace_back(k1, k2);
    return;
  }
  if (mark[k1])
    merge(k1, ch[k2][0]), merge(k1, ch[k2][1]);
  else if (mark[k2])
    merge(ch[k1][0], k2), merge(ch[k1][1], k2);
  else
    merge(ch[k1][0], ch[k2][0]), merge(ch[k1][1], ch[k2][1]);
}
int get(int k, long long l, long long r, long long p) {
  if (mark[k]) return k;
  return ((l + r) >> 1) >= p ? get(ch[k][0], l, ((l + r) >> 1), p)
                             : get(ch[k][1], ((l + r) >> 1) + 1, r, p);
}
namespace DSU {
int fa[maxV];
void init() { iota(fa + 1, fa + tot + 1, 1); }
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void unite(int x, int y) { fa[find(x)] = find(y); }
bool test(int x, int y) { return find(x) == find(y); }
}  // namespace DSU
int main() {
  scanf("%d %d", &n, &m), U = (1LL << n) - 1;
  tag[++tot] = m + 1;
  for (int i = 1; i <= m; i++) {
    scanf("%s %lld %lld", op[i], &a[i], &b[i]);
    if (op[i][0] == 'b') cov(1, 0, U, a[i], b[i], i);
  }
  dfs(1);
  for (int i = 1; i <= tot; i++) {
    if (!mark[i]) merge(ch[i][0], ch[i][1]);
  }
  DSU::init();
  for (auto &e : E[m + 1]) {
    DSU::unite(e.first, e.second);
  }
  vector<int> ans;
  for (int i = m; i; i--) {
    if (op[i][0] == 'b') {
      for (auto &e : E[i]) DSU::unite(e.first, e.second);
    } else {
      ans.push_back(DSU::test(get(1, 0, U, a[i]), get(1, 0, U, b[i])));
    }
  }
  reverse(ans.begin(), ans.end());
  for (int x : ans) printf("%d\n", x);
  return 0;
}

```