func_code_string: #include <bits/stdc++.h>   using namespace std;   long long pwr(long long base, long long p, long long mod = (1000000007LL)) {     long long ans = 1;     while (p) {       if (p & 1) ans = (ans * base) % mod;       base = (base * base) % mod;       p /= 2;     }     return ans;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   const int N = 3002;   int n, q, K[400002], ans[400002];   vector<int> adj[N], qarr[N][N], stack_;   bool visited[N], instack[N];   set<int> cycles;   void dfs(int v, int src) {     visited[v] = true;     instack[v] = true;     stack_.push_back(v);     for (auto idx : qarr[src][v]) {       if (ans[idx] != 0) continue;       if ((int)stack_.size() >= K[idx] && cycles.empty())         ans[idx] = stack_[K[idx] - 1];       else         ans[idx] = -1;     }     for (auto vv : adj[v]) {       if (!visited[vv]) {         dfs(vv, src);       } else if (instack[vv]) {         cycles.insert(vv);       }     }     instack[v] = false;     cycles.erase(v);     stack_.pop_back();   }   int main() {     int m;     scanf( %d%d%d , &n, &m, &q);     while (m--) {       int a, b;       scanf( %d%d , &a, &b);       adj[a].push_back(b);     }     for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end());     for (int i = 1; i <= q; i++) {       int s, t, k;       scanf( %d%d%d , &s, &t, &k);       K[i] = k;       qarr[s][t].push_back(i);     }     for (int i = 1; i <= n; i++) {       memset(visited, 0, sizeof(visited));       memset(instack, 0, sizeof(instack));       cycles.clear();       stack_.clear();       dfs(i, i);     }     for (int i = 1; i <= q; i++) {       if (ans[i] == 0) ans[i] = -1;       printf( %d n , ans[i]);     }     return 0;   }   