#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, mod = 1e9 + 7;
long long n, m, q, z, qt[N], ql[N], qr[N], ans[N], bl[N], br[N], asdf[N],
    f[N * 20], lg[N * 2], st[N][20], nid[N][20], sh[N][20];
pair<long long, long long> a[N];
vector<pair<long long, long long>> ed[N];
long long find(long long u) { return f[u] == u ? u : f[u] = find(f[u]); }
signed main() {
  scanf("%lld%lld", &n, &q);
  for (long long i = 2; i < 2 * N; i++) lg[i] = lg[i >> 1] + 1;
  a[++m] = {-1, -q - 1}, a[++m] = {1ll << n, q + 1};
  for (long long i = 1; i <= q; i++) {
    char s[10];
    scanf("%s%lld%lld", s, &ql[i], &qr[i]);
    qt[i] = (s[0] == 'b' ? 1 : 2);
    if (qt[i] == 1) a[++m] = {ql[i], -i}, a[++m] = {qr[i], i};
  }
  sort(a + 1, a + m + 1);
  for (long long i = 1; i < m; i++) {
    long long cl = a[i].first + (i & 1), cr = a[i + 1].first - (i & 1),
              cc = (i & 1 ? q + 1 : -a[i].second);
    if (cl > cr) continue;
    if (cl == cr)
      bl[++z] = cl, br[z] = cr, asdf[z] = cc;
    else {
      long long fk = cl ^ cr;
      while (fk != (fk & -fk)) fk ^= fk & -fk;
      long long mid = cl | (fk - 1);
      bl[++z] = cl, br[z] = mid, asdf[z] = cc, bl[++z] = mid + 1, br[z] = cr,
      asdf[z] = cc;
    }
  }
  long long ptr = z;
  for (long long i = 1; i <= z; i++)
    for (long long k = n - 1; k >= 0; k--) {
      long long cl, cr;
      bool die = false;
      if (br[i] - bl[i] > (1ll << k))
        cr = bl[i] | ((1ll << (k + 1)) - 1), cl = cr ^ ((1ll << (k + 1)) - 1),
        die = true;
      else
        cl = bl[i] ^ (1ll << k), cr = br[i] ^ (1ll << k);
      long long zl = lower_bound(br + 1, br + z + 1, cl) - br,
                zr = lower_bound(bl + 1, bl + z + 1, cr + 1) - bl - 1;
      for (long long j = zl; j <= zr; j++)
        ed[min(asdf[j], asdf[i])].push_back({i, j});
      if (die) break;
    }
  for (long long i = 1; i <= ptr; i++) f[i] = i;
  for (long long i = q + 1; i >= 1; i--) {
    for (auto c : ed[i]) f[find(c.first)] = find(c.second);
    if (qt[i] == 2)
      ans[i] = find(lower_bound(br + 1, br + z + 1, ql[i]) - br) ==
               find(lower_bound(br + 1, br + z + 1, qr[i]) - br);
  }
  for (long long i = 1; i <= q; i++)
    if (qt[i] == 2) printf("%lld\n", ans[i]);
  return 0;
}

### Prompt

Your task is to create 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;
const long long N = 2e5 + 5, mod = 1e9 + 7;
long long n, m, q, z, qt[N], ql[N], qr[N], ans[N], bl[N], br[N], asdf[N],
    f[N * 20], lg[N * 2], st[N][20], nid[N][20], sh[N][20];
pair<long long, long long> a[N];
vector<pair<long long, long long>> ed[N];
long long find(long long u) { return f[u] == u ? u : f[u] = find(f[u]); }
signed main() {
  scanf("%lld%lld", &n, &q);
  for (long long i = 2; i < 2 * N; i++) lg[i] = lg[i >> 1] + 1;
  a[++m] = {-1, -q - 1}, a[++m] = {1ll << n, q + 1};
  for (long long i = 1; i <= q; i++) {
    char s[10];
    scanf("%s%lld%lld", s, &ql[i], &qr[i]);
    qt[i] = (s[0] == 'b' ? 1 : 2);
    if (qt[i] == 1) a[++m] = {ql[i], -i}, a[++m] = {qr[i], i};
  }
  sort(a + 1, a + m + 1);
  for (long long i = 1; i < m; i++) {
    long long cl = a[i].first + (i & 1), cr = a[i + 1].first - (i & 1),
              cc = (i & 1 ? q + 1 : -a[i].second);
    if (cl > cr) continue;
    if (cl == cr)
      bl[++z] = cl, br[z] = cr, asdf[z] = cc;
    else {
      long long fk = cl ^ cr;
      while (fk != (fk & -fk)) fk ^= fk & -fk;
      long long mid = cl | (fk - 1);
      bl[++z] = cl, br[z] = mid, asdf[z] = cc, bl[++z] = mid + 1, br[z] = cr,
      asdf[z] = cc;
    }
  }
  long long ptr = z;
  for (long long i = 1; i <= z; i++)
    for (long long k = n - 1; k >= 0; k--) {
      long long cl, cr;
      bool die = false;
      if (br[i] - bl[i] > (1ll << k))
        cr = bl[i] | ((1ll << (k + 1)) - 1), cl = cr ^ ((1ll << (k + 1)) - 1),
        die = true;
      else
        cl = bl[i] ^ (1ll << k), cr = br[i] ^ (1ll << k);
      long long zl = lower_bound(br + 1, br + z + 1, cl) - br,
                zr = lower_bound(bl + 1, bl + z + 1, cr + 1) - bl - 1;
      for (long long j = zl; j <= zr; j++)
        ed[min(asdf[j], asdf[i])].push_back({i, j});
      if (die) break;
    }
  for (long long i = 1; i <= ptr; i++) f[i] = i;
  for (long long i = q + 1; i >= 1; i--) {
    for (auto c : ed[i]) f[find(c.first)] = find(c.second);
    if (qt[i] == 2)
      ans[i] = find(lower_bound(br + 1, br + z + 1, ql[i]) - br) ==
               find(lower_bound(br + 1, br + z + 1, qr[i]) - br);
  }
  for (long long i = 1; i <= q; i++)
    if (qt[i] == 2) printf("%lld\n", ans[i]);
  return 0;
}

```