#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
int n, m, fa[3000010], ch[3000010][2], id[3000010], cnt = 0, ndcnt = 0;
bool vis[3000010];
char buf[10];
vector<pair<pair<long long, long long>, int> > qry;
vector<long long> allv;
vector<int> ans, vt[3000010];
int getf(int x) { return x == fa[x] ? x : fa[x] = getf(fa[x]); }
void add_seg(int cur, long long l, long long r, long long tl, long long tr) {
  if (l <= tl && tr <= r) {
    id[cur] = cnt++;
    return;
  }
  long long mid = (tl + tr) >> 1;
  if (mid >= l) {
    if (ch[cur][0] == -1) {
      ch[cur][0] = ++ndcnt;
    }
    add_seg(ch[cur][0], l, r, tl, mid);
  }
  if (mid < r) {
    if (ch[cur][1] == -1) {
      ch[cur][1] = ++ndcnt;
    }
    add_seg(ch[cur][1], l, r, mid + 1, tr);
  }
  return;
}
void dfs(int l, int r, int curdep, int dest) {
  if (id[l] != -1 && id[r] != -1) {
    if (curdep >= dest) {
      return;
    }
    vt[id[l]].push_back(id[r]);
    vt[id[r]].push_back(id[l]);
    return;
  }
  if (id[r] != -1) {
    swap(l, r);
  }
  if (id[l] != -1) {
    if (ch[r][0] != -1) {
      dfs(l, ch[r][0], curdep - 1, dest);
    }
    if (ch[r][1] != -1) {
      dfs(l, ch[r][1], curdep - 1, dest);
    }
    return;
  }
  if (curdep == dest) {
    if (l > r) {
      swap(l, r);
    }
    if (ch[l][0] != -1 && ch[r][1] != -1) {
      dfs(ch[l][0], ch[r][1], curdep - 1, dest);
    }
    return;
  }
  if (ch[l][0] != -1 && ch[r][0] != -1) {
    dfs(ch[l][0], ch[r][0], curdep - 1, dest);
  }
  if (ch[l][1] != -1 && ch[r][1] != -1) {
    dfs(ch[l][1], ch[r][1], curdep - 1, dest);
  }
  return;
}
int get_bel(long long x) {
  int cur = 0, i;
  for (i = n - 1; i >= 0; i--) {
    if (id[cur] != -1) {
      return id[cur];
    }
    if (x & ((long long)1 << i)) {
      cur = ch[cur][1];
    } else {
      cur = ch[cur][0];
    }
  }
  return id[cur];
}
void modify(long long l, long long r) {
  int i, j;
  l = get_bel(l);
  r = get_bel(r);
  for (i = l; i <= r; i++) {
    vis[i] = true;
    for (j = 0; j < vt[i].size(); j++) {
      if (vis[vt[i][j]]) {
        fa[getf(vt[i][j])] = getf(i);
      }
    }
  }
  return;
}
int main() {
  int i;
  long long l, r;
  for (i = 0; i < 3000010; i++) {
    id[i] = ch[i][0] = ch[i][1] = -1;
    fa[i] = i;
  }
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%s", &buf);
    scanf("%lld%lld", &l, &r);
    if (buf[0] == 'a') {
      qry.push_back(make_pair(make_pair(l, r), 0));
    } else {
      allv.push_back(l);
      allv.push_back(r);
      qry.push_back(make_pair(make_pair(l, r), 1));
    }
  }
  allv.push_back(-1);
  allv.push_back(((long long)1 << n));
  sort(allv.begin(), allv.end());
  long long rt = 0;
  for (i = 1; i < allv.size(); i++) {
    if (i & 1) {
      if (allv[i] - 1 >= allv[i - 1] + 1) {
        add_seg(0, allv[i - 1] + 1, allv[i] - 1, 0, ((long long)1 << n) - 1);
      }
    } else {
      add_seg(0, allv[i - 1], allv[i], 0, ((long long)1 << n) - 1);
    }
  }
  for (i = 0; i < n; i++) {
    dfs(0, 0, n - 1, i);
  }
  for (i = 1; i < allv.size(); i += 2) {
    if (allv[i] - 1 >= allv[i - 1] + 1) {
      modify(allv[i - 1] + 1, allv[i] - 1);
    }
  }
  reverse(qry.begin(), qry.end());
  for (i = 0; i < m; i++) {
    if (qry[i].second == 0) {
      ans.push_back(getf(get_bel(qry[i].first.first)) ==
                    getf(get_bel(qry[i].first.second)));
    } else {
      modify(qry[i].first.first, qry[i].first.second);
    }
  }
  reverse(ans.begin(), ans.end());
  for (i = 0; i < ans.size(); i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

### Prompt

Create a solution in cpp for the following problem:

<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>
#pragma GCC optimize(2)
using namespace std;
int n, m, fa[3000010], ch[3000010][2], id[3000010], cnt = 0, ndcnt = 0;
bool vis[3000010];
char buf[10];
vector<pair<pair<long long, long long>, int> > qry;
vector<long long> allv;
vector<int> ans, vt[3000010];
int getf(int x) { return x == fa[x] ? x : fa[x] = getf(fa[x]); }
void add_seg(int cur, long long l, long long r, long long tl, long long tr) {
  if (l <= tl && tr <= r) {
    id[cur] = cnt++;
    return;
  }
  long long mid = (tl + tr) >> 1;
  if (mid >= l) {
    if (ch[cur][0] == -1) {
      ch[cur][0] = ++ndcnt;
    }
    add_seg(ch[cur][0], l, r, tl, mid);
  }
  if (mid < r) {
    if (ch[cur][1] == -1) {
      ch[cur][1] = ++ndcnt;
    }
    add_seg(ch[cur][1], l, r, mid + 1, tr);
  }
  return;
}
void dfs(int l, int r, int curdep, int dest) {
  if (id[l] != -1 && id[r] != -1) {
    if (curdep >= dest) {
      return;
    }
    vt[id[l]].push_back(id[r]);
    vt[id[r]].push_back(id[l]);
    return;
  }
  if (id[r] != -1) {
    swap(l, r);
  }
  if (id[l] != -1) {
    if (ch[r][0] != -1) {
      dfs(l, ch[r][0], curdep - 1, dest);
    }
    if (ch[r][1] != -1) {
      dfs(l, ch[r][1], curdep - 1, dest);
    }
    return;
  }
  if (curdep == dest) {
    if (l > r) {
      swap(l, r);
    }
    if (ch[l][0] != -1 && ch[r][1] != -1) {
      dfs(ch[l][0], ch[r][1], curdep - 1, dest);
    }
    return;
  }
  if (ch[l][0] != -1 && ch[r][0] != -1) {
    dfs(ch[l][0], ch[r][0], curdep - 1, dest);
  }
  if (ch[l][1] != -1 && ch[r][1] != -1) {
    dfs(ch[l][1], ch[r][1], curdep - 1, dest);
  }
  return;
}
int get_bel(long long x) {
  int cur = 0, i;
  for (i = n - 1; i >= 0; i--) {
    if (id[cur] != -1) {
      return id[cur];
    }
    if (x & ((long long)1 << i)) {
      cur = ch[cur][1];
    } else {
      cur = ch[cur][0];
    }
  }
  return id[cur];
}
void modify(long long l, long long r) {
  int i, j;
  l = get_bel(l);
  r = get_bel(r);
  for (i = l; i <= r; i++) {
    vis[i] = true;
    for (j = 0; j < vt[i].size(); j++) {
      if (vis[vt[i][j]]) {
        fa[getf(vt[i][j])] = getf(i);
      }
    }
  }
  return;
}
int main() {
  int i;
  long long l, r;
  for (i = 0; i < 3000010; i++) {
    id[i] = ch[i][0] = ch[i][1] = -1;
    fa[i] = i;
  }
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%s", &buf);
    scanf("%lld%lld", &l, &r);
    if (buf[0] == 'a') {
      qry.push_back(make_pair(make_pair(l, r), 0));
    } else {
      allv.push_back(l);
      allv.push_back(r);
      qry.push_back(make_pair(make_pair(l, r), 1));
    }
  }
  allv.push_back(-1);
  allv.push_back(((long long)1 << n));
  sort(allv.begin(), allv.end());
  long long rt = 0;
  for (i = 1; i < allv.size(); i++) {
    if (i & 1) {
      if (allv[i] - 1 >= allv[i - 1] + 1) {
        add_seg(0, allv[i - 1] + 1, allv[i] - 1, 0, ((long long)1 << n) - 1);
      }
    } else {
      add_seg(0, allv[i - 1], allv[i], 0, ((long long)1 << n) - 1);
    }
  }
  for (i = 0; i < n; i++) {
    dfs(0, 0, n - 1, i);
  }
  for (i = 1; i < allv.size(); i += 2) {
    if (allv[i] - 1 >= allv[i - 1] + 1) {
      modify(allv[i - 1] + 1, allv[i] - 1);
    }
  }
  reverse(qry.begin(), qry.end());
  for (i = 0; i < m; i++) {
    if (qry[i].second == 0) {
      ans.push_back(getf(get_bel(qry[i].first.first)) ==
                    getf(get_bel(qry[i].first.second)));
    } else {
      modify(qry[i].first.first, qry[i].first.second);
    }
  }
  reverse(ans.begin(), ans.end());
  for (i = 0; i < ans.size(); i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

```