#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + ch - '0', ch = getchar();
  return s * f;
}
inline int getopt() {
  char ch = getchar();
  int ret = 0;
  while (ch < 'a' || ch > 'b') ch = getchar();
  ret = (ch == 'b');
  while (ch >= 'a' && ch <= 'z') ch = getchar();
  return ret;
}
const int M = 5e4 + 5, N = 55;
int n, m;
vector<pair<int, int> > buc[M];
namespace SGT {
int ls[N * M * 2], rs[N * M * 2], tag[N * M * 2], inde;
inline void pushdown(int id) {
  if (!tag[id]) return;
  if (!ls[id]) ls[id] = ++inde, tag[ls[id]] = tag[id];
  if (!rs[id]) rs[id] = ++inde, tag[rs[id]] = tag[id];
  tag[id] = 0;
}
inline void init() { tag[inde = 1] = m + 1; }
void cover(int id, long long l, long long r, long long L, long long R, int t) {
  if (L <= l && r <= R) {
    tag[id] = t;
    return;
  }
  pushdown(id);
  if (L <= ((l + r) >> 1)) cover(ls[id], l, ((l + r) >> 1), L, R, t);
  if (R > ((l + r) >> 1)) cover(rs[id], ((l + r) >> 1) + 1, r, L, R, t);
}
inline bool leaf(int id) { return !ls[id] && !rs[id]; }
inline int findpos(int id, long long l, long long r, long long p) {
  if (leaf(id)) return id;
  if (p <= ((l + r) >> 1))
    return findpos(ls[id], l, ((l + r) >> 1), p);
  else
    return findpos(rs[id], ((l + r) >> 1) + 1, r, p);
}
void merge(int x, int y) {
  if (leaf(x) && leaf(y))
    buc[min(tag[x], tag[y])].push_back(make_pair(x, y));
  else
    merge(leaf(x) ? x : ls[x], leaf(y) ? y : ls[y]),
        merge(leaf(x) ? x : rs[x], leaf(y) ? y : rs[y]);
}
inline void build() {
  for (int i = 1; i <= inde; ++i)
    if (!leaf(i)) merge(ls[i], rs[i]);
}
}  // namespace SGT
int fa[N * M * 2], opt[M], ans[M];
long long l[M], r[M];
int find_fa(int x) { return x == fa[x] ? x : fa[x] = find_fa(fa[x]); }
int main() {
  n = read();
  m = read();
  SGT::init();
  long long mx = (1ll << n) - 1;
  for (int i = 1; i <= m; ++i) {
    opt[i] = getopt();
    l[i] = read();
    r[i] = read();
    if (opt[i]) SGT::cover(1, 0, mx, l[i], r[i], i);
  }
  SGT::build();
  opt[m + 1] = 1;
  for (int i = 1; i <= SGT::inde; ++i) fa[i] = i;
  for (int i = m + 1; i >= 1; --i) {
    if (opt[i])
      for (pair<int, int> j : buc[i])
        fa[find_fa(j.first)] = fa[find_fa(j.second)];
    else {
      int x = SGT::findpos(1, 0, mx, l[i]), y = SGT::findpos(1, 0, mx, r[i]);
      ans[i] = (find_fa(x) == find_fa(y));
    }
  }
  for (int i = 1; i <= m; ++i)
    if (!opt[i]) putchar(ans[i] + '0'), puts("");
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

<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;
inline long long read() {
  long long s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + ch - '0', ch = getchar();
  return s * f;
}
inline int getopt() {
  char ch = getchar();
  int ret = 0;
  while (ch < 'a' || ch > 'b') ch = getchar();
  ret = (ch == 'b');
  while (ch >= 'a' && ch <= 'z') ch = getchar();
  return ret;
}
const int M = 5e4 + 5, N = 55;
int n, m;
vector<pair<int, int> > buc[M];
namespace SGT {
int ls[N * M * 2], rs[N * M * 2], tag[N * M * 2], inde;
inline void pushdown(int id) {
  if (!tag[id]) return;
  if (!ls[id]) ls[id] = ++inde, tag[ls[id]] = tag[id];
  if (!rs[id]) rs[id] = ++inde, tag[rs[id]] = tag[id];
  tag[id] = 0;
}
inline void init() { tag[inde = 1] = m + 1; }
void cover(int id, long long l, long long r, long long L, long long R, int t) {
  if (L <= l && r <= R) {
    tag[id] = t;
    return;
  }
  pushdown(id);
  if (L <= ((l + r) >> 1)) cover(ls[id], l, ((l + r) >> 1), L, R, t);
  if (R > ((l + r) >> 1)) cover(rs[id], ((l + r) >> 1) + 1, r, L, R, t);
}
inline bool leaf(int id) { return !ls[id] && !rs[id]; }
inline int findpos(int id, long long l, long long r, long long p) {
  if (leaf(id)) return id;
  if (p <= ((l + r) >> 1))
    return findpos(ls[id], l, ((l + r) >> 1), p);
  else
    return findpos(rs[id], ((l + r) >> 1) + 1, r, p);
}
void merge(int x, int y) {
  if (leaf(x) && leaf(y))
    buc[min(tag[x], tag[y])].push_back(make_pair(x, y));
  else
    merge(leaf(x) ? x : ls[x], leaf(y) ? y : ls[y]),
        merge(leaf(x) ? x : rs[x], leaf(y) ? y : rs[y]);
}
inline void build() {
  for (int i = 1; i <= inde; ++i)
    if (!leaf(i)) merge(ls[i], rs[i]);
}
}  // namespace SGT
int fa[N * M * 2], opt[M], ans[M];
long long l[M], r[M];
int find_fa(int x) { return x == fa[x] ? x : fa[x] = find_fa(fa[x]); }
int main() {
  n = read();
  m = read();
  SGT::init();
  long long mx = (1ll << n) - 1;
  for (int i = 1; i <= m; ++i) {
    opt[i] = getopt();
    l[i] = read();
    r[i] = read();
    if (opt[i]) SGT::cover(1, 0, mx, l[i], r[i], i);
  }
  SGT::build();
  opt[m + 1] = 1;
  for (int i = 1; i <= SGT::inde; ++i) fa[i] = i;
  for (int i = m + 1; i >= 1; --i) {
    if (opt[i])
      for (pair<int, int> j : buc[i])
        fa[find_fa(j.first)] = fa[find_fa(j.second)];
    else {
      int x = SGT::findpos(1, 0, mx, l[i]), y = SGT::findpos(1, 0, mx, r[i]);
      ans[i] = (find_fa(x) == find_fa(y));
    }
  }
  for (int i = 1; i <= m; ++i)
    if (!opt[i]) putchar(ans[i] + '0'), puts("");
  return 0;
}

```