func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 5;   struct edge {     int u, v, w, num;   } e[N], c[N];   map<long long, int> mp;   int n, m, q, s, siz[N], fa[N];   long long L[N], R[N];   bool vis[N];   int find(int x) { return fa[x] ? fa[x] = find(fa[x]) : x; }   bool comp(edge x, edge y) { return x.w < y.w; }   int main() {     int i, j, k, x, num;     scanf( %d%d , &n, &m);     for (i = 1; i <= m; i++) {       scanf( %d%d%d , &c[i].u, &c[i].v, &c[i].w);       c[i].num = i;     }     sort(c + 1, c + 1 + m, comp);     for (i = 1; i <= m; i++) siz[c[i].num] = i;     for (i = 1; i <= m; i = j + 1) {       for (j = i; j < m && c[j + 1].w == c[i].w; j++)         ;       for (k = i; k <= j; k++)         L[c[k].num] = 1LL * c[k].w * m + find(c[k].u),         R[c[k].num] = 1LL * c[k].w * m + find(c[k].v);       for (k = i; k <= j; k++)         if (find(c[k].u) != find(c[k].v)) fa[find(c[k].u)] = find(c[k].v);     }     memset(fa, 0, sizeof(fa));     scanf( %d , &q);     for (i = 1; i <= q; i++) {       scanf( %d , &s);       mp.clear();       bool flag = true;       num = 0;       for (j = 1; j <= s; j++) {         scanf( %d , &x);         if (!mp[L[x]]) fa[mp[L[x]] = ++num] = 0;         if (!mp[R[x]]) fa[mp[R[x]] = ++num] = 0;         if (find(mp[L[x]]) == find(mp[R[x]]))           flag = 0;         else           fa[find(mp[L[x]])] = find(mp[R[x]]);       }       puts(flag ?  YES  :  NO );     }     return 0;   }   