#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
const long long N = 5e5 + 5;
const long long mod = 998244353;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
long long test = 1, n, mx, mn, sz[N];
vector<pair<long long, long long> > adj[N];
void dfsmax(int x, int p) {
  sz[x] = 1;
  for (auto it : adj[x]) {
    if (it.first == p) continue;
    dfsmax(it.first, x);
    sz[x] += sz[it.first];
    mx += it.second * min(sz[it.first], 2 * n - sz[it.first]);
  }
}
void dfsmin(int x, int p) {
  sz[x] = 1;
  for (auto it : adj[x]) {
    if (it.first == p) continue;
    dfsmin(it.first, x);
    sz[x] ^= sz[it.first];
    mn += it.second * sz[it.first];
  }
}
void solve() {
  mx = mn = 0;
  cin >> n;
  for (int i = 1; i < 2 * n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  dfsmax(1, 0);
  dfsmin(1, 0);
  cout << mn << " " << mx << "\n";
  for (int i = 1; i <= 2 * n; i++) adj[i].clear();
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(15);
  ;
  cin >> test;
  for (int i = 1; i <= test; i++) {
    solve();
  }
}
