#include <bits/stdc++.h>
using namespace std;
long long modI(long long a, long long m);
long long gcd(long long a, long long b);
long long powM(long long x, long long y, long long m);
long long swap(long long a, long long b);
void swap(long long& a, long long& b) {
  long long tp = a;
  a = b;
  b = tp;
}
long long gcd(long long x, long long y) {
  if (x == 0) return y;
  return gcd(y % x, x);
}
long long powM(long long x, long long y, long long m) {
  long long ans = 1, r = 1;
  x %= m;
  while (r > 0 && r <= y) {
    if (r & y) {
      ans *= x;
      ans %= m;
    }
    r <<= 1;
    x *= x;
    x %= m;
  }
  return ans;
}
long long modI(long long a, long long m) {
  long long m0 = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m;
    a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
vector<vector<pair<int, long long>>> adj;
long long a1, a2;
int n;
int dfs(int v, int p) {
  int sz = 1;
  for (pair<int, long long> it : adj[v]) {
    if (it.first == p) continue;
    int tpsz = dfs(it.first, v);
    sz += tpsz;
    if (tpsz & 1) a1 += it.second;
    a2 += it.second * min(n - tpsz, tpsz);
  }
  return sz;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int tt = 1;
  cin >> tt;
  while (tt--) {
    a1 = 0, a2 = 0;
    cin >> n;
    n = n * 2;
    adj.assign(n + 1, {});
    int z = n - 1;
    while (z--) {
      int a, b, w;
      cin >> a >> b >> w;
      adj[a].push_back({b, w});
      adj[b].push_back({a, w});
    }
    dfs(1, -1);
    cout << a1 << " " << a2 << endl;
  }
  return 0;
}
