func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 5;   int par[N], par1[N], T, vis[N], n, m, w[N], x[N], y[N];   bool ans[N];   vector<pair<int, int>> e[N], q[N];   int get(int u) { return u == par[u] ? u : par[u] = get(par[u]); }   int gett(int u) {     return (vis[u] != T ? vis[u] = T, par1[u] = par[u] : 0),            (u == par1[u] ? u : par1[u] = gett(par1[u]));   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) par[i] = i;     for (int i = 0, a, b, c; i < m; i++)       scanf( %d%d%d , x + i, y + i, w + i), e[w[i]].push_back({--x[i], --y[i]});     scanf( %d , &n);     for (int i = 0, a, b; i < n; i++) {       scanf( %d , &a);       while (a--) scanf( %d , &b), --b, q[w[b]].push_back({i, b});     }     for (int i = 1, last; i < N; i++) {       last = -1;       for (auto j : q[i]) {         if (last != j.first) T++, last = j.first;         int a = gett(x[j.second]), b = gett(y[j.second]);         if (a == b)           ans[last] = 1;         else           par1[a] = b;       }       for (auto j : e[i]) par[get(j.second)] = get(j.first);     }     for (int i = 0; i < n; i++) puts(ans[i] ?  NO  :  YES );   }   