#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1000 * 100 + 100;
int n, sz[N];
vector<pair<int, int>> adj[N];
pair<long long, long long> makeGoodPlace(int root, int par = -1) {
  pair<long long, long long> res = {0, 0};
  int cnt = 0;
  for (auto u : adj[root])
    if (u.first ^ par) {
      pair<long long, long long> t = makeGoodPlace(u.first, root);
      if (t.second != -1) cnt++;
      res.first += t.first + (t.second != -1 ? t.second + u.second : 0);
    }
  return {res.first, (cnt & 1 ? -1 : 0)};
}
long long AbeautifulHell(int root, int par = -1) {
  long long res = 0;
  for (auto u : adj[root])
    if (u.first ^ par) {
      long long t = AbeautifulHell(u.first, root);
      res += t;
      sz[root] += sz[u.first];
      res += 1LL * min(sz[u.first], n * 2 - sz[u.first]) * u.second;
    }
  sz[root]++;
  return res;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int Q;
  cin >> Q;
  while (Q--) {
    cin >> n;
    for (int i = 1, v, u, w; i < 2 * n; i++) {
      cin >> v >> u >> w;
      adj[v].push_back({u, w});
      adj[u].push_back({v, w});
    }
    long long G = makeGoodPlace(1).first, B = AbeautifulHell(1);
    cout << G << ' ' << B << endl;
    for (int i = 1; i <= n << 1; i++) adj[i].clear(), sz[i] = 0;
  }
  return 0;
}
