func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace flyinthesky {   const int MAXN = 500000 + 5;   struct edge {     int u, v, w;     bool operator<(const edge &b) const { return w < b.w; }   } ed[MAXN], ed2[MAXN];   struct whw {     int id, fr, t;   };   struct ask {     int id;     bool operator<(const ask &b) const { return ed[id].w < ed[b.id].w; }   };   int n, m, q, ans[MAXN], maxw = 0, f[MAXN], sz[MAXN];   vector<whw> a[MAXN];   vector<ask> que[MAXN];   stack<pair<int, int> > s;   int find(int x) { return x == f[x] ? x : find(f[x]); }   void mg(int a, int b) {     int x = a, y = b;     if (sz[x] > sz[y]) swap(x, y);     f[x] = y, sz[y] += sz[x], s.push(make_pair(x, y));   }   void cc(int tms) {     while (tms-- && !s.empty()) {       pair<int, int> p = s.top();       s.pop();       int x = p.first, y = p.second;       f[x] = x, sz[y] -= sz[x];     }   }   void clean() { memset(ans, 0, sizeof ans); }   int solve() {     cin >> n >> m;     clean();     for (int i = 1; i <= m; ++i)       scanf( %d%d%d , &ed[i].u, &ed[i].v, &ed[i].w), maxw = max(maxw, ed[i].w),                                                      ed2[i] = ed[i];     sort(ed2 + 1, ed2 + 1 + m);     cin >> q;     for (int i = 1; i <= q; ++i) {       int Ki;       scanf( %d , &Ki);       for (int x, j = 1; j <= Ki; ++j)         scanf( %d , &x), que[i].push_back((ask){x});       sort(que[i].begin(), que[i].end());       int lst = 0;       for (int j = 1; j < (int)que[i].size(); ++j) {         int id = que[i][j].id, lid = que[i][j - 1].id;         if (ed[id].w != ed[lid].w) {           a[ed[lid].w].push_back((whw){i, lst, j - 1});           lst = j;         }       }       a[ed[que[i][(int)que[i].size() - 1].id].w].push_back(           (whw){i, lst, (int)que[i].size() - 1});     }     for (int i = 0; i <= n; ++i) f[i] = i, sz[i] = 1;     int now = 1;     for (int i = 1; i <= maxw; ++i) {       for (int j = 0; j < (int)a[i].size(); ++j) {         int fl = 0, tms = 0;         whw &ct = a[i][j];         for (int k = ct.fr; k <= ct.t; ++k) {           edge &e = ed[que[ct.id][k].id];           int x = find(e.u), y = find(e.v);           if (x == y) {             fl = 1;             break;           } else             mg(x, y), ++tms;         }         if (fl) ans[ct.id] = 1;         cc(tms);       }       while (ed2[now].w == i) {         int x = find(ed2[now].u), y = find(ed2[now].v);         if (x != y) mg(x, y);         ++now;       }     }     for (int i = 1; i <= q; ++i) printf( %s , ans[i] == 1 ?  NO n  :  YES n );     return 0;   }   }  // namespace flyinthesky   int main() {     flyinthesky::solve();     return 0;   }   