#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  int nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  long long ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
void print(vector<int> x) {
  for (int i = 0; i < (int)x.size(); i++)
    printf("%d%c", x[i], " \n"[i == (int)x.size() - 1]);
}
int ls[50005 * 55 * 4], rs[50005 * 55 * 4], hav[50005 * 55 * 4];
int fa[50005 * 55 * 4], ok[50005 * 55 * 4], cnt = 1, rt = 1;
int find(int u) { return fa[u] == u ? u : fa[u] = find(fa[u]); }
int n, Q, op[100005], ans[100005];
long long l[100005], r[100005], t[100005 * 2];
char _s[100005];
long long ful;
void merge(int u, int v) { fa[find(u)] = find(v); }
void ins(int &u, long long l, long long r, long long L, long long R) {
  if (L > R) return;
  if (!u) u = ++cnt, fa[u] = u;
  if (L <= l && r <= R) return;
  long long mid = (l + r) / 2;
  if (mid >= L) ins(ls[u], l, (l + r) / 2, L, R);
  if (mid < R) ins(rs[u], (l + r) / 2 + 1, r, L, R);
}
int query(int u, long long l, long long r, long long L, long long R) {
  if (L > R) return -1;
  if (!u) return -1;
  if (L <= l && r <= R && !ok[u]) return -1;
  if (!ok[u]) return -1;
  if (!ls[u] && !rs[u]) return u;
  long long mid = (l + r) / 2;
  if (mid >= L) {
    int res = query(ls[u], l, mid, L, R);
    if (res != -1) return res;
  }
  if (mid < R) {
    int res = query(rs[u], mid + 1, r, L, R);
    if (res != -1) return res;
  }
  return -1;
}
void update(int u, long long l, long long r, long long L, long long R, int to) {
  if (!u) return;
  if (!ok[u]) return;
  if (!ls[u] && !rs[u]) {
    hav[u] = u, merge(u, to);
    return;
  }
  if (hav[u]) {
    merge(hav[u], to);
    return;
  }
  long long mid = (l + r) / 2;
  if (mid >= L) update(ls[u], l, mid, L, R, to);
  if (mid < R) update(rs[u], mid + 1, r, L, R, to);
  if (find(hav[ls[u]]) == find(hav[rs[u]])) hav[u] = find(hav[ls[u]]);
}
struct Node {
  long long l1, r1, l2, r2;
};
Node get(long long l, long long r, long long L, long long R) {
  if (L == R) return (Node){L, R, L, R};
  while (1) {
    long long mid = (l + r) / 2;
    int A = mid >= L, B = mid < R;
    if (A && B) return (Node){L, mid, mid + 1, R};
    if (mid >= L)
      r = mid;
    else
      l = mid + 1;
  }
}
void fix(int u, long long l, long long r, long long L, long long R) {
  if (L > R) return;
  if (L <= l && r <= R) {
    ok[u] = 1;
    return;
  }
  long long mid = (l + r) / 2;
  if (mid >= L) fix(ls[u], l, (l + r) / 2, L, R);
  if (mid < R) fix(rs[u], (l + r) / 2 + 1, r, L, R);
  if (mid >= L) {
    long long vl = max(L, l), vr = min(mid, R);
    Node qwq = get(l, mid, vl, vr);
    vl = qwq.l1, vr = qwq.r1;
    update(rs[u], mid + 1, r, vl - l + mid + 1, vr - l + mid + 1,
           query(ls[u], l, mid, vl, vr));
    vl = qwq.l2, vr = qwq.r2;
    update(rs[u], mid + 1, r, vl - l + mid + 1, vr - l + mid + 1,
           query(ls[u], l, mid, vl, vr));
  }
  if (mid < R) {
    long long vl = max(L, mid + 1), vr = min(R, r);
    Node qwq = get(mid + 1, r, vl, vr);
    vl = qwq.l1, vr = qwq.r1;
    update(ls[u], l, mid, vl - mid - 1 + l, vr - mid - 1 + l,
           query(rs[u], mid + 1, r, vl, vr));
    vl = qwq.l2, vr = qwq.r2;
    update(ls[u], l, mid, vl - mid - 1 + l, vr - mid - 1 + l,
           query(rs[u], mid + 1, r, vl, vr));
  }
  ok[u] = ok[ls[u]] | ok[rs[u]];
}
int getfa(int u, long long l, long long r, long long pos) {
  if (!ls[u] && !rs[u]) {
    return find(u);
  }
  long long mid = (l + r) / 2;
  if (pos <= mid)
    return getfa(ls[u], l, mid, pos);
  else
    return getfa(rs[u], mid + 1, r, pos);
}
signed main() {
  cin >> n >> Q;
  ful = (1ll << n) - 1;
  int cnt = 0;
  for (int i = 1; i <= Q; i++) {
    scanf("%s", _s + 1);
    op[i] = _s[1] == 'a';
    l[i] = read(), r[i] = read();
    if (op[i] == 0)
      ins(rt, 0, ful, l[i], r[i]), t[++cnt] = l[i], t[++cnt] = r[i];
  }
  if (cnt == 0) {
    for (int i = 1; i <= Q; i++) printf("%d\n", 1);
    return 0;
  }
  sort(t + 1, t + cnt + 1);
  if (t[1] != 0) ins(rt, 0, ful, 0, t[1] - 1);
  if (t[cnt] != ful) ins(rt, 0, ful, t[cnt] + 1, ful);
  for (int i = 2; i <= cnt; i += 2)
    if (t[i] + 1 <= t[i + 1] - 1) ins(rt, 0, ful, t[i] + 1, t[i + 1] - 1);
  if (t[1] != 0) fix(rt, 0, ful, 0, t[1] - 1);
  if (t[cnt] != ful) fix(rt, 0, ful, t[cnt] + 1, ful);
  for (int i = 2; i <= cnt; i += 2)
    if (t[i] + 1 <= t[i + 1] - 1) fix(rt, 0, ful, t[i] + 1, t[i + 1] - 1);
  for (int i = Q; i >= 1; i--) {
    if (!op[i])
      fix(rt, 0, ful, l[i], r[i]);
    else
      ans[i] = getfa(rt, 0, ful, l[i]) == getfa(rt, 0, ful, r[i]);
  }
  for (int i = 1; i <= Q; i++)
    if (op[i]) printf("%d\n", ans[i]);
  return 0;
}

### Prompt

Create a solution in cpp for 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;
inline long long read() {
  char ch = getchar();
  int nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  long long ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
void print(vector<int> x) {
  for (int i = 0; i < (int)x.size(); i++)
    printf("%d%c", x[i], " \n"[i == (int)x.size() - 1]);
}
int ls[50005 * 55 * 4], rs[50005 * 55 * 4], hav[50005 * 55 * 4];
int fa[50005 * 55 * 4], ok[50005 * 55 * 4], cnt = 1, rt = 1;
int find(int u) { return fa[u] == u ? u : fa[u] = find(fa[u]); }
int n, Q, op[100005], ans[100005];
long long l[100005], r[100005], t[100005 * 2];
char _s[100005];
long long ful;
void merge(int u, int v) { fa[find(u)] = find(v); }
void ins(int &u, long long l, long long r, long long L, long long R) {
  if (L > R) return;
  if (!u) u = ++cnt, fa[u] = u;
  if (L <= l && r <= R) return;
  long long mid = (l + r) / 2;
  if (mid >= L) ins(ls[u], l, (l + r) / 2, L, R);
  if (mid < R) ins(rs[u], (l + r) / 2 + 1, r, L, R);
}
int query(int u, long long l, long long r, long long L, long long R) {
  if (L > R) return -1;
  if (!u) return -1;
  if (L <= l && r <= R && !ok[u]) return -1;
  if (!ok[u]) return -1;
  if (!ls[u] && !rs[u]) return u;
  long long mid = (l + r) / 2;
  if (mid >= L) {
    int res = query(ls[u], l, mid, L, R);
    if (res != -1) return res;
  }
  if (mid < R) {
    int res = query(rs[u], mid + 1, r, L, R);
    if (res != -1) return res;
  }
  return -1;
}
void update(int u, long long l, long long r, long long L, long long R, int to) {
  if (!u) return;
  if (!ok[u]) return;
  if (!ls[u] && !rs[u]) {
    hav[u] = u, merge(u, to);
    return;
  }
  if (hav[u]) {
    merge(hav[u], to);
    return;
  }
  long long mid = (l + r) / 2;
  if (mid >= L) update(ls[u], l, mid, L, R, to);
  if (mid < R) update(rs[u], mid + 1, r, L, R, to);
  if (find(hav[ls[u]]) == find(hav[rs[u]])) hav[u] = find(hav[ls[u]]);
}
struct Node {
  long long l1, r1, l2, r2;
};
Node get(long long l, long long r, long long L, long long R) {
  if (L == R) return (Node){L, R, L, R};
  while (1) {
    long long mid = (l + r) / 2;
    int A = mid >= L, B = mid < R;
    if (A && B) return (Node){L, mid, mid + 1, R};
    if (mid >= L)
      r = mid;
    else
      l = mid + 1;
  }
}
void fix(int u, long long l, long long r, long long L, long long R) {
  if (L > R) return;
  if (L <= l && r <= R) {
    ok[u] = 1;
    return;
  }
  long long mid = (l + r) / 2;
  if (mid >= L) fix(ls[u], l, (l + r) / 2, L, R);
  if (mid < R) fix(rs[u], (l + r) / 2 + 1, r, L, R);
  if (mid >= L) {
    long long vl = max(L, l), vr = min(mid, R);
    Node qwq = get(l, mid, vl, vr);
    vl = qwq.l1, vr = qwq.r1;
    update(rs[u], mid + 1, r, vl - l + mid + 1, vr - l + mid + 1,
           query(ls[u], l, mid, vl, vr));
    vl = qwq.l2, vr = qwq.r2;
    update(rs[u], mid + 1, r, vl - l + mid + 1, vr - l + mid + 1,
           query(ls[u], l, mid, vl, vr));
  }
  if (mid < R) {
    long long vl = max(L, mid + 1), vr = min(R, r);
    Node qwq = get(mid + 1, r, vl, vr);
    vl = qwq.l1, vr = qwq.r1;
    update(ls[u], l, mid, vl - mid - 1 + l, vr - mid - 1 + l,
           query(rs[u], mid + 1, r, vl, vr));
    vl = qwq.l2, vr = qwq.r2;
    update(ls[u], l, mid, vl - mid - 1 + l, vr - mid - 1 + l,
           query(rs[u], mid + 1, r, vl, vr));
  }
  ok[u] = ok[ls[u]] | ok[rs[u]];
}
int getfa(int u, long long l, long long r, long long pos) {
  if (!ls[u] && !rs[u]) {
    return find(u);
  }
  long long mid = (l + r) / 2;
  if (pos <= mid)
    return getfa(ls[u], l, mid, pos);
  else
    return getfa(rs[u], mid + 1, r, pos);
}
signed main() {
  cin >> n >> Q;
  ful = (1ll << n) - 1;
  int cnt = 0;
  for (int i = 1; i <= Q; i++) {
    scanf("%s", _s + 1);
    op[i] = _s[1] == 'a';
    l[i] = read(), r[i] = read();
    if (op[i] == 0)
      ins(rt, 0, ful, l[i], r[i]), t[++cnt] = l[i], t[++cnt] = r[i];
  }
  if (cnt == 0) {
    for (int i = 1; i <= Q; i++) printf("%d\n", 1);
    return 0;
  }
  sort(t + 1, t + cnt + 1);
  if (t[1] != 0) ins(rt, 0, ful, 0, t[1] - 1);
  if (t[cnt] != ful) ins(rt, 0, ful, t[cnt] + 1, ful);
  for (int i = 2; i <= cnt; i += 2)
    if (t[i] + 1 <= t[i + 1] - 1) ins(rt, 0, ful, t[i] + 1, t[i + 1] - 1);
  if (t[1] != 0) fix(rt, 0, ful, 0, t[1] - 1);
  if (t[cnt] != ful) fix(rt, 0, ful, t[cnt] + 1, ful);
  for (int i = 2; i <= cnt; i += 2)
    if (t[i] + 1 <= t[i + 1] - 1) fix(rt, 0, ful, t[i] + 1, t[i + 1] - 1);
  for (int i = Q; i >= 1; i--) {
    if (!op[i])
      fix(rt, 0, ful, l[i], r[i]);
    else
      ans[i] = getfa(rt, 0, ful, l[i]) == getfa(rt, 0, ful, r[i]);
  }
  for (int i = 1; i <= Q; i++)
    if (op[i]) printf("%d\n", ans[i]);
  return 0;
}

```