func_code_string: #include <bits/stdc++.h>   using namespace std;   const int max_n = 1e5 + 10;   vector<long long> adj[max_n];   long long par[max_n], st[max_n], p[max_n], ft[max_n], doc[max_n], x[max_n],       l[max_n], r[max_n], cnt, tmp, k, n, m;   bool mark[max_n];   int get_par(int u) { return par[u] == u ? u : par[u] = get_par(par[u]); }   void dfs(long long v) {     st[v] = cnt++;     for (auto u : adj[v]) dfs(u);     ft[v] = cnt;   }   bool cmp(long long v, long long u) {     if (get_par(v) == get_par(u) && st[v] >= st[u] && ft[v] <= ft[u])       return true;     else       return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       par[i] = i;       p[i] = i;     }     while (m--) {       int t;       cin >> t;       long long v, u;       if (t == 1) {         cin >> v >> u;         par[v] = u;         p[v] = u;       } else if (t == 2) {         cin >> v;         l[tmp] = v;         r[tmp++] = get_par(v);       } else {         cin >> x[k] >> doc[k];         doc[k++]--;       }     }     for (int i = 1; i <= n; ++i) {       if (p[i] != i) adj[p[i]].push_back(i);     }     for (int i = 1; i <= n; ++i) {       if (p[i] == i) {         cnt = 0;         dfs(i);       }     }     for (int i = 0; i < k; ++i) {       if (cmp(l[doc[i]], x[i]) && cmp(x[i], r[doc[i]]))         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }   