func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( O2 )   #pragma GCC optimize( unroll-loops )   using namespace std;   const long double eps = 1e-7;   const int inf = 1000000010;   const long long INF = 10000000000000010LL;   const int mod = 1000000007;   const int MAXN = 200010, LOG = 20;   struct DSU {     int par[MAXN];     int rank[MAXN];     stack<pair<int*, int>> stk;     DSU() {       for (int i = 1; i < MAXN; i++) par[i] = i;     }     int get(int x) {       if (par[x] == x) return x;       return get(par[x]);     }     int join(int x, int y) {       x = get(x);       y = get(y);       if (x == y) return 0;       if (rank[x] > rank[y]) swap(x, y);       stk.push({&par[x], par[x]});       stk.push({&rank[y], rank[y]});       par[x] = y;       rank[y] += (rank[x] == rank[y]);       return 1;     }     void undo(int cnt = 1) {       cnt <<= 1;       while (cnt--) {         auto it = stk.top();         stk.pop();         *it.first = it.second;       }     }   } dsu;   int n, m, k, u, v, x, y, a, b, last;   int T[MAXN], X[MAXN], Y[MAXN];   map<pair<int, int>, vector<int>> mp;   vector<pair<int, int>> seg[MAXN << 2];   set<pair<int, int>> edge;   string out;   int f(int x) {     if (x == n) return 1;     return x + 1;   }   pair<int, int> ff(int x, int y) {     if (x > y) swap(x, y);     return {x, y};   }   void Add(int id, int tl, int tr, int l, int r, pair<int, int> p) {     if (r <= tl || tr <= l) return;     if (l <= tl && tr <= r) {       seg[id].push_back(p);       return;     }     int mid = (tl + tr) >> 1;     Add(id << 1, tl, mid, l, r, p);     Add(id << 1 | 1, mid, tr, l, r, p);   }   void handle(int i) {     if (T[i] == 2) return;     if (last) X[i] = f(X[i]), Y[i] = f(Y[i]);     pair<int, int> p = ff(X[i], Y[i]);     if (edge.count(p))       edge.erase(p);     else       edge.insert(p);   }   void dfs(int id, int tl, int tr) {     int cnt = 0;     for (pair<int, int> p : seg[id])       if (edge.count(p)) cnt += dsu.join(p.first, p.second);     if (tr - tl == 1) {       if (T[tl] == 1)         ;       else {         int i = tl;         if (last) X[i] = f(X[i]), Y[i] = f(Y[i]);         out +=  0  + (last = (dsu.get(X[i]) == dsu.get(Y[i])));       }     } else {       int mid = (tl + tr) >> 1;       dfs(id << 1, tl, mid);       handle(mid);       dfs(id << 1 | 1, mid, tr);     }     dsu.undo(cnt);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= m; i++) {       cin >> T[i] >> X[i] >> Y[i];       mp[ff(X[i], Y[i])].push_back(i);       mp[ff(f(X[i]), f(Y[i]))].push_back(i);     }     for (auto it : mp) {       it.second.push_back(m + 1);       for (int i = 0; i < it.second.size() - 1; i++)         Add(1, 1, m + 1, it.second[i], it.second[i + 1], it.first);     }     handle(1);     dfs(1, 1, m + 1);     cout << out <<   n ;     return 0;   }   