#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int N = 2e5 + 555;   int n, m, q, z;   pair<long long, int> a[N];   int qt[N];   long long ql[N], qr[N];   long long ans[N];   vector<pair<int, int> > ed[N];   long long bl[N], br[N], arin[N];   int f[N * 20];   const int iu = 18;   int lg[N * 2];   long long st[N][iu], nid[N][iu];   long long sh[N][iu];   void adde(int u, int v, int t) { ed[t].push_back({u, v}); }   void add(int id, int l, int r) {     int duh = lg[r - l + 1];     int e = r - (1 << duh) + 1;     st[l][duh] = max(st[l][duh], min(arin[id], sh[l][duh]));     st[e][duh] = max(st[e][duh], min(arin[id], sh[e][duh]));     adde(id, nid[l][duh], min(arin[id], sh[l][duh]));     adde(id, nid[e][duh], min(arin[id], sh[e][duh]));   }   int find(int x) {     if (f[x] != x) f[x] = find(f[x]);     return f[x];   }   void join(int x, int y) {     x = find(x);     y = find(y);     f[x] = y;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> q;     for (int i = 2; i < 262144; i++) lg[i] = lg[i / 2] + 1;     a[++m] = {-1, -q - 1};     a[++m] = {1LL << n, q + 1};     for (int i = 1; i <= q; i++) {       string s;       cin >> s >> ql[i] >> qr[i];       if (s[0] ==  b )         qt[i] = 1;       else         qt[i] = 2;       if (qt[i] == 1) {         a[++m] = {ql[i], -i};         a[++m] = {qr[i], i};       }     }     sort(a + 1, a + m + 1);     for (int i = 1; i < m; i++) {       long long cl = a[i].first + (i % 2);       long long cr = a[i + 1].first - (i % 2);       int cc;       if (i % 2 == 1)         cc = q + 1;       else         cc = -a[i].second;       if (cl > cr) continue;       if (cl == cr) {         bl[++z] = cl;         br[z] = cr;         arin[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;         arin[z] = cc;         bl[++z] = mid + 1;         br[z] = cr;         arin[z] = cc;       }     }     int ptr = z;     for (int j = 0; j < iu; j++) {       for (int i = 1; i <= z; i++) {         nid[i][j] = ++ptr;         if (j == 0)           sh[i][j] = arin[i];         else if (i + (1 << (j - 1)) <= z) {           sh[i][j] = max(sh[i][j - 1], sh[i + (1 << (j - 1))][j - 1]);         }       }     }     for (int i = 1; i <= z; i++) {       for (int k = n - 1; k >= 0; k--) {         long long cl, cr;         bool die = false;         if (br[i] - bl[i] + 1 > (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);         }         int zl = lower_bound(br + 1, br + z + 1, cl) - br;         int zr = lower_bound(bl + 1, bl + z + 1, cr + 1) - bl - 1;         add(i, zl, zr);         if (die) break;       }       adde(i, nid[i][0], arin[i]);     }     for (int j = iu - 2; j >= 0; j--) {       for (int i = 1; i <= z; i++) {         st[i][j] = max(st[i][j], st[i][j + 1]);         adde(nid[i][j], nid[i][j + 1], min(st[i][j + 1], sh[i][j]));         if (i > (1 << j)) {           st[i][j] = max(st[i][j], st[i - (1 << j)][j + 1]);           adde(nid[i][j], nid[i - (1 << j)][j + 1],                min(st[i - (1 << j)][j + 1], sh[i][j]));         }       }     }     for (int i = 1; i <= ptr; i++) f[i] = i;     for (int i = q + 1; i >= 1; i--) {       for (auto c : ed[i]) join(c.first, c.second);       if (qt[i] == 2) {         int cl = lower_bound(br + 1, br + z + 1, ql[i]) - br;         int cr = lower_bound(br + 1, br + z + 1, qr[i]) - br;         ans[i] = find(cl) == find(cr);       }     }     for (int i = 1; i <= q; i++) {       if (qt[i] == 2) cout << ans[i] <<   n ;     }   }