#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &f) {
  f = 0;
  T fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') {
      fu = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= fu;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + 48);
  else
    print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
  print(x);
  putchar(t);
}
const int N = 2e5 + 5;
vector<int> adj[N];
long long a[N], b[N], l[N], r[N];
int opt[N], id[N], ban[N], f[N], ans[N];
char c[10];
int n, m, len;
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
bool cmp(int i, int j) { return l[i] < l[j]; }
void add(long long L, long long R, int _ban) {
  for (int i = n; i >= 0; i--) {
    if (((R + 1) >> i) != (L >> i)) {
      long long pos = (((R + 1) >> i) << i) - 1;
      ++len;
      l[len] = L;
      r[len] = pos;
      ban[len] = _ban;
      if (pos != R) {
        ++len;
        l[len] = pos + 1;
        r[len] = R;
        ban[len] = _ban;
      }
      break;
    }
  }
}
void insert(int u) {
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    if (!ban[v]) {
      f[find(u)] = find(v);
    }
  }
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= m; i++) {
    scanf("%s", c + 1);
    read(a[i]);
    read(b[i]);
    opt[i] = (c[1] == 'a');
    if (opt[i] == 0) {
      ++len;
      l[len] = a[i];
      r[len] = b[i];
    }
  }
  {
    static long long tl[N], tr[N], tlen;
    for (int i = 1; i <= len; i++) id[i] = i;
    sort(id + 1, id + len + 1, cmp);
    for (int i = 1; i <= len; i++) {
      tl[i] = l[id[i]];
      tr[i] = r[id[i]];
    }
    tlen = len;
    len = 0;
    tr[0] = -1;
    for (int i = 1; i <= tlen; i++) {
      if (tr[i - 1] + 1 <= tl[i] - 1) {
        add(tr[i - 1] + 1, tl[i] - 1, 0);
      }
      add(tl[i], tr[i], 1);
    }
    if (tr[tlen] != (1ll << n) - 1) add(tr[tlen] + 1, (1ll << n) - 1, 0);
  }
  for (int bit = 0; bit < n; bit++) {
    for (int i = 1, j = 1; i <= len; i++) {
      long long pos = -1;
      if ((l[i] >> bit) & 1)
        pos = l[i];
      else
        pos = ((l[i] >> bit) + 1) << bit;
      if (l[i] <= pos && pos <= r[i]) {
        while (pos - (1ll << bit) > r[j]) ++j;
        adj[i].push_back(j);
        adj[j].push_back(i);
      }
    }
    for (int i = len, j = len; i >= 1; i--) {
      long long pos = -1;
      if (((l[i] >> bit) & 1) == 0)
        pos = l[i];
      else
        pos = ((l[i] >> bit) + 1) << bit;
      if (l[i] <= pos && pos <= r[i]) {
        while (pos + (1ll << bit) < l[j]) --j;
        adj[i].push_back(j);
        adj[j].push_back(i);
      }
    }
  }
  for (int i = 1; i <= len; i++) f[i] = i;
  for (int i = 1; i <= len; i++) {
    if (!ban[i]) {
      insert(i);
    }
  }
  for (int i = m; i >= 1; i--) {
    if (opt[i] == 0) {
      int pos = lower_bound(r + 1, r + len + 1, b[i]) - r;
      while (pos && l[pos] >= a[i]) {
        ban[pos] = 0;
        insert(pos);
        --pos;
      }
    }
    if (opt[i] == 1) {
      int p1 = lower_bound(r + 1, r + len + 1, a[i]) - r;
      int p2 = lower_bound(r + 1, r + len + 1, b[i]) - r;
      if (find(p1) == find(p2)) ans[i] = 1;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (opt[i] == 1) {
      print(ans[i], '\n');
    }
  }
  return 0;
}

### Prompt

Develop a solution in CPP 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;
template <typename T>
inline void read(T &f) {
  f = 0;
  T fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') {
      fu = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= fu;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + 48);
  else
    print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
  print(x);
  putchar(t);
}
const int N = 2e5 + 5;
vector<int> adj[N];
long long a[N], b[N], l[N], r[N];
int opt[N], id[N], ban[N], f[N], ans[N];
char c[10];
int n, m, len;
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
bool cmp(int i, int j) { return l[i] < l[j]; }
void add(long long L, long long R, int _ban) {
  for (int i = n; i >= 0; i--) {
    if (((R + 1) >> i) != (L >> i)) {
      long long pos = (((R + 1) >> i) << i) - 1;
      ++len;
      l[len] = L;
      r[len] = pos;
      ban[len] = _ban;
      if (pos != R) {
        ++len;
        l[len] = pos + 1;
        r[len] = R;
        ban[len] = _ban;
      }
      break;
    }
  }
}
void insert(int u) {
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    if (!ban[v]) {
      f[find(u)] = find(v);
    }
  }
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= m; i++) {
    scanf("%s", c + 1);
    read(a[i]);
    read(b[i]);
    opt[i] = (c[1] == 'a');
    if (opt[i] == 0) {
      ++len;
      l[len] = a[i];
      r[len] = b[i];
    }
  }
  {
    static long long tl[N], tr[N], tlen;
    for (int i = 1; i <= len; i++) id[i] = i;
    sort(id + 1, id + len + 1, cmp);
    for (int i = 1; i <= len; i++) {
      tl[i] = l[id[i]];
      tr[i] = r[id[i]];
    }
    tlen = len;
    len = 0;
    tr[0] = -1;
    for (int i = 1; i <= tlen; i++) {
      if (tr[i - 1] + 1 <= tl[i] - 1) {
        add(tr[i - 1] + 1, tl[i] - 1, 0);
      }
      add(tl[i], tr[i], 1);
    }
    if (tr[tlen] != (1ll << n) - 1) add(tr[tlen] + 1, (1ll << n) - 1, 0);
  }
  for (int bit = 0; bit < n; bit++) {
    for (int i = 1, j = 1; i <= len; i++) {
      long long pos = -1;
      if ((l[i] >> bit) & 1)
        pos = l[i];
      else
        pos = ((l[i] >> bit) + 1) << bit;
      if (l[i] <= pos && pos <= r[i]) {
        while (pos - (1ll << bit) > r[j]) ++j;
        adj[i].push_back(j);
        adj[j].push_back(i);
      }
    }
    for (int i = len, j = len; i >= 1; i--) {
      long long pos = -1;
      if (((l[i] >> bit) & 1) == 0)
        pos = l[i];
      else
        pos = ((l[i] >> bit) + 1) << bit;
      if (l[i] <= pos && pos <= r[i]) {
        while (pos + (1ll << bit) < l[j]) --j;
        adj[i].push_back(j);
        adj[j].push_back(i);
      }
    }
  }
  for (int i = 1; i <= len; i++) f[i] = i;
  for (int i = 1; i <= len; i++) {
    if (!ban[i]) {
      insert(i);
    }
  }
  for (int i = m; i >= 1; i--) {
    if (opt[i] == 0) {
      int pos = lower_bound(r + 1, r + len + 1, b[i]) - r;
      while (pos && l[pos] >= a[i]) {
        ban[pos] = 0;
        insert(pos);
        --pos;
      }
    }
    if (opt[i] == 1) {
      int p1 = lower_bound(r + 1, r + len + 1, a[i]) - r;
      int p2 = lower_bound(r + 1, r + len + 1, b[i]) - r;
      if (find(p1) == find(p2)) ans[i] = 1;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (opt[i] == 1) {
      print(ans[i], '\n');
    }
  }
  return 0;
}

```