#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 7, M = N * 110;
int ls[M], rs[M], n, m, i, ans[N], tag[M], fa[M], sz = 1, op[N];
vector<pair<int, int> > e[M];
long long U, l[N], r[N];
char s[100];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline int lea(int x) { return !ls[x] && !rs[x]; }
void pd(int x) {
  if (!ls[x]) ls[x] = ++sz, tag[sz] = tag[x];
  if (!rs[x]) rs[x] = ++sz, tag[sz] = tag[x];
  tag[x] = 0;
}
void I(int x, long long l, long long r, long long a, long long b, int t) {
  if (a <= l && r <= b) {
    tag[x] = t;
    return;
  }
  long long mid = l + r >> 1;
  pd(x);
  if (a <= mid) I(ls[x], l, mid, a, b, t);
  if (b > mid) I(rs[x], mid + 1, r, a, b, t);
}
void dfs(int x, int y) {
  if (lea(x) && lea(y))
    return e[min(tag[x], tag[y])].push_back(pair<int, int>(x, y));
  if (lea(x)) return dfs(x, ls[y]), dfs(x, rs[y]);
  if (lea(y)) return dfs(ls[x], y), dfs(rs[x], y);
  dfs(ls[x], ls[y]);
  dfs(rs[x], rs[y]);
}
int Q(int x, long long l, long long r, long long p) {
  if (lea(x)) return x;
  long long mid = (l + r) >> 1;
  return p <= mid ? Q(ls[x], l, mid, p) : Q(rs[x], mid + 1, r, p);
}
void ins(int z) {
  for (auto data : e[z]) fa[find(data.first)] = find(data.second);
}
int main() {
  for (scanf("%d%d", &n, &m), U = (1LL << n) - 1, tag[1] = m + 1, i = 1; i <= m;
       ++i) {
    scanf("%s%lld%lld", s, l + i, r + i);
    op[i] = s[0] == 'a';
    if (s[0] == 'b') I(1, 0, U, l[i], r[i], i);
  }
  for (i = 1; i <= sz; fa[i] = i, ++i)
    if (!lea(i)) dfs(ls[i], rs[i]);
  for (ins(m + 1), i = m; i; --i) {
    ins(i);
    if (op[i]) ans[i] = find(Q(1, 0, U, l[i])) == find(Q(1, 0, U, r[i]));
  }
  for (i = 1; i <= m; ++i)
    if (op[i]) printf("%d\n", ans[i]);
}

### Prompt

Construct a cpp code solution to the problem outlined:

<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 N = 5e4 + 7, M = N * 110;
int ls[M], rs[M], n, m, i, ans[N], tag[M], fa[M], sz = 1, op[N];
vector<pair<int, int> > e[M];
long long U, l[N], r[N];
char s[100];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline int lea(int x) { return !ls[x] && !rs[x]; }
void pd(int x) {
  if (!ls[x]) ls[x] = ++sz, tag[sz] = tag[x];
  if (!rs[x]) rs[x] = ++sz, tag[sz] = tag[x];
  tag[x] = 0;
}
void I(int x, long long l, long long r, long long a, long long b, int t) {
  if (a <= l && r <= b) {
    tag[x] = t;
    return;
  }
  long long mid = l + r >> 1;
  pd(x);
  if (a <= mid) I(ls[x], l, mid, a, b, t);
  if (b > mid) I(rs[x], mid + 1, r, a, b, t);
}
void dfs(int x, int y) {
  if (lea(x) && lea(y))
    return e[min(tag[x], tag[y])].push_back(pair<int, int>(x, y));
  if (lea(x)) return dfs(x, ls[y]), dfs(x, rs[y]);
  if (lea(y)) return dfs(ls[x], y), dfs(rs[x], y);
  dfs(ls[x], ls[y]);
  dfs(rs[x], rs[y]);
}
int Q(int x, long long l, long long r, long long p) {
  if (lea(x)) return x;
  long long mid = (l + r) >> 1;
  return p <= mid ? Q(ls[x], l, mid, p) : Q(rs[x], mid + 1, r, p);
}
void ins(int z) {
  for (auto data : e[z]) fa[find(data.first)] = find(data.second);
}
int main() {
  for (scanf("%d%d", &n, &m), U = (1LL << n) - 1, tag[1] = m + 1, i = 1; i <= m;
       ++i) {
    scanf("%s%lld%lld", s, l + i, r + i);
    op[i] = s[0] == 'a';
    if (s[0] == 'b') I(1, 0, U, l[i], r[i], i);
  }
  for (i = 1; i <= sz; fa[i] = i, ++i)
    if (!lea(i)) dfs(ls[i], rs[i]);
  for (ins(m + 1), i = m; i; --i) {
    ins(i);
    if (op[i]) ans[i] = find(Q(1, 0, U, l[i])) == find(Q(1, 0, U, r[i]));
  }
  for (i = 1; i <= m; ++i)
    if (op[i]) printf("%d\n", ans[i]);
}

```