func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   int sz[N];   struct Edge {     long long from, to, val, nex;   } edge[N];   int h[N], idx;   void add(long long u, long long v, long long w) {     Edge E = {u, v, w, h[u]};     edge[idx] = E;     h[u] = idx++;   }   void init() {     memset(h, -1, sizeof(h));     idx = 0;   }   long long ans;   void dfs1(int u, int fa) {     sz[u] = 1;     for (int i = h[u]; ~i; i = edge[i].nex) {       int v = edge[i].to;       if (v == fa) continue;       dfs1(v, u);       sz[u] += sz[v];       if (sz[v] & 1) {         ans += edge[i].val;       }     }   }   int n;   long long ans2;   void dfs2(int u, int fa) {     sz[u] = 1;     for (int i = h[u]; ~i; i = edge[i].nex) {       int v = edge[i].to;       if (v == fa) continue;       dfs2(v, u);       sz[u] += sz[v];       ans2 += min(sz[v], n - sz[v]) * edge[i].val;     }   }   int main() {     int t;     cin >> t;     while (t--) {       cin >> n;       n = n * 2;       init();       ans = ans2 = 0;       for (int i = 1; i < n; i++) {         long long u, v, w;         cin >> u >> v >> w;         add(u, v, w);         add(v, u, w);       }       dfs1(1, -1);       printf( %lld  , ans);       dfs2(1, -1);       printf( %lld  , ans2);       cout << endl;     }     return 0;   }   