#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e4 + 5, MAXM = 1e7;
int n, m;
long long a[MAXN], b[MAXN];
int ans[MAXN];
int cntp, rt, lc[MAXM], rc[MAXM], tag[MAXM];
inline void add(int &k, int v) {
  if (!k) k = ++cntp;
  tag[k] = v;
}
inline void pushdwn(int k) {
  if (tag[k]) {
    add(lc[k], tag[k]);
    add(rc[k], tag[k]);
    tag[k] = 0;
  }
}
void Modify(int &k, long long l, long long r, long long x, long long y, int v) {
  if (!k) k = ++cntp;
  if (x <= l && r <= y) return add(k, v);
  pushdwn(k);
  long long mid = l + r >> 1;
  if (x <= mid) Modify(lc[k], l, mid, x, y, v);
  if (mid < y) Modify(rc[k], mid + 1, r, x, y, v);
  return;
}
int Query(int k, long long l, long long r, long long w) {
  if (tag[k]) return k;
  long long mid = l + r >> 1;
  if (w <= mid) return Query(lc[k], l, mid, w);
  return Query(rc[k], mid + 1, r, w);
}
int pre[MAXM];
int fnd(int x) {
  if (x != pre[x]) pre[x] = fnd(pre[x]);
  return pre[x];
}
vector<pair<int, int> > vec[MAXN];
void Dfs2(int k, int p) {
  if (tag[k] && tag[p]) {
    vec[min(tag[k], tag[p])].push_back(make_pair(k, p));
    return;
  }
  int l = lc[k], r = lc[p];
  if (!l) l = k;
  if (!r) r = p;
  Dfs2(l, r);
  l = rc[k], r = rc[p];
  if (!l) l = k;
  if (!r) r = p;
  Dfs2(l, r);
  return;
}
void Dfs1(int k) {
  if (!lc[k]) return;
  Dfs2(lc[k], rc[k]);
  Dfs1(lc[k]);
  Dfs1(rc[k]);
  return;
}
int main() {
  scanf("%d%d", &n, &m);
  add(rt, m + 1);
  for (int i = 1; i <= m; i++) {
    char op[10];
    scanf("%s%lld%lld", op, a + i, b + i);
    if (op[0] == 'b') ans[i] = -1, Modify(rt, 0, (1ll << n) - 1, a[i], b[i], i);
  }
  Dfs1(rt);
  for (int i = 1; i <= cntp; i++) pre[i] = i;
  ans[m + 1] = -1;
  for (int i = m + 1; i; i--) {
    for (int j = 0; j < vec[i].size(); j++) {
      int x = fnd(vec[i][j].first), y = fnd(vec[i][j].second);
      if (x != y) pre[x] = y;
    }
    if (!ans[i])
      ans[i] = (fnd(Query(rt, 0, (1ll << n) - 1, a[i])) ==
                fnd(Query(rt, 0, (1ll << n) - 1, b[i])));
  }
  for (int i = 1; i <= m; i++)
    if (ans[i] >= 0) printf("%d\n", ans[i]);
  return 0;
}

### 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 MAXN = 5e4 + 5, MAXM = 1e7;
int n, m;
long long a[MAXN], b[MAXN];
int ans[MAXN];
int cntp, rt, lc[MAXM], rc[MAXM], tag[MAXM];
inline void add(int &k, int v) {
  if (!k) k = ++cntp;
  tag[k] = v;
}
inline void pushdwn(int k) {
  if (tag[k]) {
    add(lc[k], tag[k]);
    add(rc[k], tag[k]);
    tag[k] = 0;
  }
}
void Modify(int &k, long long l, long long r, long long x, long long y, int v) {
  if (!k) k = ++cntp;
  if (x <= l && r <= y) return add(k, v);
  pushdwn(k);
  long long mid = l + r >> 1;
  if (x <= mid) Modify(lc[k], l, mid, x, y, v);
  if (mid < y) Modify(rc[k], mid + 1, r, x, y, v);
  return;
}
int Query(int k, long long l, long long r, long long w) {
  if (tag[k]) return k;
  long long mid = l + r >> 1;
  if (w <= mid) return Query(lc[k], l, mid, w);
  return Query(rc[k], mid + 1, r, w);
}
int pre[MAXM];
int fnd(int x) {
  if (x != pre[x]) pre[x] = fnd(pre[x]);
  return pre[x];
}
vector<pair<int, int> > vec[MAXN];
void Dfs2(int k, int p) {
  if (tag[k] && tag[p]) {
    vec[min(tag[k], tag[p])].push_back(make_pair(k, p));
    return;
  }
  int l = lc[k], r = lc[p];
  if (!l) l = k;
  if (!r) r = p;
  Dfs2(l, r);
  l = rc[k], r = rc[p];
  if (!l) l = k;
  if (!r) r = p;
  Dfs2(l, r);
  return;
}
void Dfs1(int k) {
  if (!lc[k]) return;
  Dfs2(lc[k], rc[k]);
  Dfs1(lc[k]);
  Dfs1(rc[k]);
  return;
}
int main() {
  scanf("%d%d", &n, &m);
  add(rt, m + 1);
  for (int i = 1; i <= m; i++) {
    char op[10];
    scanf("%s%lld%lld", op, a + i, b + i);
    if (op[0] == 'b') ans[i] = -1, Modify(rt, 0, (1ll << n) - 1, a[i], b[i], i);
  }
  Dfs1(rt);
  for (int i = 1; i <= cntp; i++) pre[i] = i;
  ans[m + 1] = -1;
  for (int i = m + 1; i; i--) {
    for (int j = 0; j < vec[i].size(); j++) {
      int x = fnd(vec[i][j].first), y = fnd(vec[i][j].second);
      if (x != y) pre[x] = y;
    }
    if (!ans[i])
      ans[i] = (fnd(Query(rt, 0, (1ll << n) - 1, a[i])) ==
                fnd(Query(rt, 0, (1ll << n) - 1, b[i])));
  }
  for (int i = 1; i <= m; i++)
    if (ans[i] >= 0) printf("%d\n", ans[i]);
  return 0;
}

```