#include <bits/stdc++.h>
using namespace std;
int n, m, len, ans[400020];
long long b[400020];
vector<int> G[400020];
bool vis[400020], live[400020];
void adde(int u, int v) { G[u].push_back(v), G[v].push_back(u); }
struct Query {
  long long l, r;
  int opt;
} q[400020];
class Union_Set {
 public:
  int f[400020];
  void init(int n) {
    for (int i = 1; i <= n; ++i) f[i] = i;
  }
  inline int getf(int x) { return f[x] == x ? x : f[x] = getf(f[x]); }
  void Merge(int x, int y) {
    int fx = getf(x), fy = getf(y);
    if (fx ^ fy) f[fy] = fx;
  }
} S;
void Insert(int u) {
  live[u] = 1;
  for (auto v : G[u])
    if (live[v]) S.Merge(u, v);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  b[len = 1] = 0;
  for (int i = 1; i <= m; ++i) {
    string s;
    cin >> s >> q[i].l >> q[i].r;
    q[i].opt = s[0] == 'b';
    if (q[i].opt) {
      b[++len] = q[i].l, b[++len] = q[i].r + 1;
    }
  }
  b[++len] = 1LL << n;
  sort(b + 1, b + len + 1);
  for (int i = 1, jb = len; i < jb; ++i) {
    long long l = b[i], r = b[i + 1] - 1;
    if (l >= r) continue;
    long long x = 1LL << (63 - __builtin_clzll(l ^ r));
    b[++len] = x | (l ^ (l & (x - 1)));
  }
  sort(b + 1, b + len + 1);
  len = unique(b + 1, b + len + 1) - b - 2;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 1; ++j) {
      for (int k = 1, p = 1; k <= len; ++k) {
        if ((b[k] >> i & 1) == j) {
          long long v = b[k] ^ (1LL << i);
          while (v >= b[p + 1]) ++p;
          if (p ^ k) adde(p, k);
        }
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (q[i].opt) {
      int l = lower_bound(b + 1, b + len + 1, q[i].l) - b;
      int r = upper_bound(b + 1, b + len + 1, q[i].r) - b - 1;
      for (int j = l; j <= r; ++j) vis[j] = 1;
    }
  }
  S.init(len);
  for (int i = 1; i <= len; ++i)
    if (!vis[i]) Insert(i);
  for (int i = m; i >= 1; --i) {
    if (q[i].opt) {
      int l = lower_bound(b + 1, b + len + 1, q[i].l) - b;
      int r = upper_bound(b + 1, b + len + 1, q[i].r) - b - 1;
      for (int j = l; j <= r; ++j) Insert(j);
    } else {
      int u = upper_bound(b + 1, b + len + 1, q[i].l) - b - 1;
      int v = upper_bound(b + 1, b + len + 1, q[i].r) - b - 1;
      ans[i] = S.getf(u) == S.getf(v);
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (!q[i].opt) cout << ans[i] << '\n';
  }
  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 n, m, len, ans[400020];
long long b[400020];
vector<int> G[400020];
bool vis[400020], live[400020];
void adde(int u, int v) { G[u].push_back(v), G[v].push_back(u); }
struct Query {
  long long l, r;
  int opt;
} q[400020];
class Union_Set {
 public:
  int f[400020];
  void init(int n) {
    for (int i = 1; i <= n; ++i) f[i] = i;
  }
  inline int getf(int x) { return f[x] == x ? x : f[x] = getf(f[x]); }
  void Merge(int x, int y) {
    int fx = getf(x), fy = getf(y);
    if (fx ^ fy) f[fy] = fx;
  }
} S;
void Insert(int u) {
  live[u] = 1;
  for (auto v : G[u])
    if (live[v]) S.Merge(u, v);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  b[len = 1] = 0;
  for (int i = 1; i <= m; ++i) {
    string s;
    cin >> s >> q[i].l >> q[i].r;
    q[i].opt = s[0] == 'b';
    if (q[i].opt) {
      b[++len] = q[i].l, b[++len] = q[i].r + 1;
    }
  }
  b[++len] = 1LL << n;
  sort(b + 1, b + len + 1);
  for (int i = 1, jb = len; i < jb; ++i) {
    long long l = b[i], r = b[i + 1] - 1;
    if (l >= r) continue;
    long long x = 1LL << (63 - __builtin_clzll(l ^ r));
    b[++len] = x | (l ^ (l & (x - 1)));
  }
  sort(b + 1, b + len + 1);
  len = unique(b + 1, b + len + 1) - b - 2;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 1; ++j) {
      for (int k = 1, p = 1; k <= len; ++k) {
        if ((b[k] >> i & 1) == j) {
          long long v = b[k] ^ (1LL << i);
          while (v >= b[p + 1]) ++p;
          if (p ^ k) adde(p, k);
        }
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (q[i].opt) {
      int l = lower_bound(b + 1, b + len + 1, q[i].l) - b;
      int r = upper_bound(b + 1, b + len + 1, q[i].r) - b - 1;
      for (int j = l; j <= r; ++j) vis[j] = 1;
    }
  }
  S.init(len);
  for (int i = 1; i <= len; ++i)
    if (!vis[i]) Insert(i);
  for (int i = m; i >= 1; --i) {
    if (q[i].opt) {
      int l = lower_bound(b + 1, b + len + 1, q[i].l) - b;
      int r = upper_bound(b + 1, b + len + 1, q[i].r) - b - 1;
      for (int j = l; j <= r; ++j) Insert(j);
    } else {
      int u = upper_bound(b + 1, b + len + 1, q[i].l) - b - 1;
      int v = upper_bound(b + 1, b + len + 1, q[i].r) - b - 1;
      ans[i] = S.getf(u) == S.getf(v);
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (!q[i].opt) cout << ans[i] << '\n';
  }
  return 0;
}

```