func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MAX = 1000000000;   const int N = 100005;   struct Edge {     int to, next, w, vis;   };   struct Edge e[N << 1];   int head[N], E, f[N];   struct P {     long long val;     int idx;     P(long long val, int idx) : val(val), idx(idx) {}     bool operator<(const P &h) const { return val > h.val; }   };   priority_queue<P> Q;   long long dfs(int u) {     f[u] = 1;     long long ret = 0;     for (int i = head[u]; i != -1; i = e[i].next) {       if (e[i].vis) continue;       e[i].vis = e[i ^ 1].vis = 1;       ret += e[i].w;       if (!f[e[i].to]) ret += dfs(e[i].to);     }     return ret;   }   void addedge(int u, int to, int w) {     e[E].to = to;     e[E].w = w;     e[E].vis = 0;     e[E].next = head[u];     head[u] = E++;   }   int main() {     memset(head, -1, sizeof head);     E = 0;     int n, m, p, q;     scanf( %d%d%d%d , &n, &m, &p, &q);     int uu, vv;     for (int i = 0; i < m; i++) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       addedge(u, v, w);       addedge(v, u, w);       uu = u, vv = v;     }     int tot = 0;     for (int i = 1; i <= n; i++) {       if (!f[i]) {         long long val = dfs(i);         Q.push(P(val, i));         tot++;       }     }     if (p + q < tot || tot < q) {       puts( NO );       return 0;     }     if (m == 0) {       if (p > 0 && q == n) {         puts( NO );         return 0;       }     }     puts( YES );     tot -= q;     int sum = 0;     while (sum < tot) {       P c1 = Q.top();       Q.pop();       P c2 = Q.top();       Q.pop();       printf( %d %d n , c1.idx, c2.idx);       uu = c1.idx, vv = c2.idx;       long long add = min(MAX, c1.val + c2.val + 1);       c1.val += add + c2.val;       Q.push(c1);       sum++;     }     for (int i = 0; i < p - tot; i++) {       printf( %d %d n , uu, vv);     }     return 0;   }   