#include <bits/stdc++.h>   using namespace std;   vector<long long> g[200000];   long long c[200000];   long long cnt;   void dfs(long long v, long long p = -1) {     cnt++;     long long cnt1 = cnt;     for (long long to : g[v]) {       if (to != p) {         dfs(to, v);       }     }     c[v] = cnt - cnt1 + 1;   }   signed main() {     long long t;     cin >> t;     for (long long q = 0; q < t; q++) {       long long k;       cin >> k;       k *= 2;       vector<pair<long long, long long>> edge;       long long t[k];       for (long long i = 0; i < k - 1; i++) {         long long a, b;         cin >> a >> b >> t[i];         a--;         b--;         g[a].push_back(b);         g[b].push_back(a);         edge.push_back({a, b});       }       dfs(0);       long long mnsum = 0, mxsum = 0;       for (long long i = 0; i < k - 1; i++) {         long long c1 = min(c[edge[i].first], c[edge[i].second]);         mnsum += c1 % 2 * t[i];         mxsum += min(c1, k - c1) * t[i];       }       cout << mnsum <<     << mxsum <<   n ;       for (long long i = 0; i < k; i++) {         g[i].clear();       }     }     return 0;   }   