#include <bits/stdc++.h>
using namespace std;
int cl[5000010], cr[5000010], ld[5000010], sl = 1;
bool yz[5000010];
void pushd(int x) {
  if (cl[x] == 0) {
    cl[x] = ++sl;
    yz[cl[x]] = 1;
  }
  if (cr[x] == 0) {
    cr[x] = ++sl;
    yz[cr[x]] = 1;
  }
  yz[x] = 0;
  if (ld[x] == 0) return;
  ld[cl[x]] = ld[cr[x]] = ld[x];
  ld[x] = 0;
}
vector<int> cf[50010], ve[5000010];
void addqj(int i, long long l, long long r, long long L, long long R, int x) {
  if (R <= l || r <= L) return;
  if (L <= l && r <= R) {
    ld[i] = x;
    cf[x].push_back(i);
    return;
  }
  long long m = (l + r) >> 1;
  pushd(i);
  addqj(cl[i], l, m, L, R, x);
  addqj(cr[i], m, r, L, R, x);
}
void link(int x, int y) {
  if (yz[x] && yz[y]) {
    if (ld[x] < ld[y])
      ve[x].push_back(y);
    else
      ve[y].push_back(x);
    return;
  }
  link(yz[x] ? x : cl[x], yz[y] ? y : cl[y]);
  link(yz[x] ? x : cr[x], yz[y] ? y : cr[y]);
}
int find(int i, long long l, long long r, long long x) {
  if (yz[i]) return i;
  long long m = (l + r) >> 1;
  return x < m ? find(cl[i], l, m, x) : find(cr[i], m, r, x);
}
int lx[50010], fa[5000010], ans[50010];
long long A[50010], B[50010];
int getv(int x) { return x == fa[x] ? x : fa[x] = getv(fa[x]); }
void merge(int x, int y) {
  x = getv(x);
  y = getv(y);
  if (x != y) fa[x] = y;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  ld[1] = m + 1;
  yz[1] = 1;
  for (int i = 1; i <= m; i++) {
    char zf[10];
    scanf("%s%lld%lld", zf, &A[i], &B[i]);
    lx[i] = zf[0] == 'b' ? 0 : 1;
    if (lx[i] == 0) addqj(1, 0, (1ll << n), A[i], B[i] + 1, i);
  }
  for (int i = 1; i <= sl; i++) {
    fa[i] = i;
    if (!yz[i]) link(cl[i], cr[i]);
  }
  for (int i = 1; i <= sl; i++) {
    if (ld[i] != m + 1) continue;
    for (int j = 0; j < ve[i].size(); j++) merge(i, ve[i][j]);
  }
  for (int i = m; i >= 1; i--) {
    if (lx[i])
      ans[i] = (getv(find(1, 0, (1ll << n), A[i])) ==
                getv(find(1, 0, (1ll << n), B[i])));
    else {
      for (int x = 0; x < cf[i].size(); x++) {
        int u = cf[i][x];
        for (int y = 0; y < ve[u].size(); y++) merge(u, ve[u][y]);
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (lx[i]) printf("%d\n", ans[i]);
  }
  return 0;
}

### Prompt

Generate a cpp solution to 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>
using namespace std;
int cl[5000010], cr[5000010], ld[5000010], sl = 1;
bool yz[5000010];
void pushd(int x) {
  if (cl[x] == 0) {
    cl[x] = ++sl;
    yz[cl[x]] = 1;
  }
  if (cr[x] == 0) {
    cr[x] = ++sl;
    yz[cr[x]] = 1;
  }
  yz[x] = 0;
  if (ld[x] == 0) return;
  ld[cl[x]] = ld[cr[x]] = ld[x];
  ld[x] = 0;
}
vector<int> cf[50010], ve[5000010];
void addqj(int i, long long l, long long r, long long L, long long R, int x) {
  if (R <= l || r <= L) return;
  if (L <= l && r <= R) {
    ld[i] = x;
    cf[x].push_back(i);
    return;
  }
  long long m = (l + r) >> 1;
  pushd(i);
  addqj(cl[i], l, m, L, R, x);
  addqj(cr[i], m, r, L, R, x);
}
void link(int x, int y) {
  if (yz[x] && yz[y]) {
    if (ld[x] < ld[y])
      ve[x].push_back(y);
    else
      ve[y].push_back(x);
    return;
  }
  link(yz[x] ? x : cl[x], yz[y] ? y : cl[y]);
  link(yz[x] ? x : cr[x], yz[y] ? y : cr[y]);
}
int find(int i, long long l, long long r, long long x) {
  if (yz[i]) return i;
  long long m = (l + r) >> 1;
  return x < m ? find(cl[i], l, m, x) : find(cr[i], m, r, x);
}
int lx[50010], fa[5000010], ans[50010];
long long A[50010], B[50010];
int getv(int x) { return x == fa[x] ? x : fa[x] = getv(fa[x]); }
void merge(int x, int y) {
  x = getv(x);
  y = getv(y);
  if (x != y) fa[x] = y;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  ld[1] = m + 1;
  yz[1] = 1;
  for (int i = 1; i <= m; i++) {
    char zf[10];
    scanf("%s%lld%lld", zf, &A[i], &B[i]);
    lx[i] = zf[0] == 'b' ? 0 : 1;
    if (lx[i] == 0) addqj(1, 0, (1ll << n), A[i], B[i] + 1, i);
  }
  for (int i = 1; i <= sl; i++) {
    fa[i] = i;
    if (!yz[i]) link(cl[i], cr[i]);
  }
  for (int i = 1; i <= sl; i++) {
    if (ld[i] != m + 1) continue;
    for (int j = 0; j < ve[i].size(); j++) merge(i, ve[i][j]);
  }
  for (int i = m; i >= 1; i--) {
    if (lx[i])
      ans[i] = (getv(find(1, 0, (1ll << n), A[i])) ==
                getv(find(1, 0, (1ll << n), B[i])));
    else {
      for (int x = 0; x < cf[i].size(); x++) {
        int u = cf[i][x];
        for (int y = 0; y < ve[u].size(); y++) merge(u, ve[u][y]);
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (lx[i]) printf("%d\n", ans[i]);
  }
  return 0;
}

```