func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mo = 1e9 + 7;   const int N = 1000010;   const int inf = 0x3f3f3f3f;   using namespace std;   int n, m, q, tot, ans[N], fa[N], mark[N], pa[N], tmp;   struct node {     int a, b, c;     bool operator<(const node &x) const { return c < x.c; }   } e[N], ed[N];   struct info {     int a, b;     bool operator<(const info &x) const {       if (e[a].c != e[x.a].c) return e[a].c < e[x.a].c;       return b < x.b;     }   } t[N];   int find(int x) {     if (!fa[x]) return x;     return fa[x] = find(fa[x]);   }   int find2(int x) {     if (mark[x] != tmp) pa[x] = fa[x], mark[x] = tmp;     if (!pa[x]) return x;     return pa[x] = find2(pa[x]);   }   int main() {     int a, b, c, k, x, A, B;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &a, &b, &c);       e[i] = (node){a, b, c};       ed[i] = e[i];     }     scanf( %d , &q);     for (int j = 1; j <= q; j++) {       scanf( %d , &k);       for (int i = 1; i <= k; i++) scanf( %d , &x), t[++tot] = (info){x, j};     }     sort(t + 1, t + tot + 1);     sort(ed + 1, ed + m + 1);     for (int i = 1, pos = 1, po = 1; i <= tot; i = pos) {       while (ed[po].c < e[t[i].a].c && po <= m) {         A = find(ed[po].a);         B = find(ed[po].b);         if (A != B) fa[B] = A;         po++;       }       while (e[t[pos].a].c == e[t[i].a].c && pos <= tot) {         if (t[pos].b != t[pos - 1].b || pos == i) tmp++;         x = t[pos].a;         A = find2(e[x].a);         B = find2(e[x].b);         if (A == B)           ans[t[pos].b] = 1;         else           pa[B] = A;         pos++;       }     }     for (int i = 1; i <= q; i++) {       if (!ans[i])         printf( YES n );       else         printf( NO n );     }     return 0;   }   