#include <bits/stdc++.h>
using namespace std;
void PV(vector<long long> v) {
  for (long long i = 0; i < (long long)v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
void PVV(vector<pair<long long, long long> > v) {
  for (long long i = 0; i < (long long)v.size(); i++)
    cout << v[i].first << " " << v[i].second << "\n";
}
void PA(long long v[], long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cout << v[i] << ' ';
  cout << "\n";
}
void IN(long long a[], long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cin >> a[i];
}
inline void op() {}
const long long M = 1e9 + 7;
const long long IM = 1e18 + 37;
const long long N = 1e6 + 10;
vector<pair<long long, long long> > v[N];
long long G, B, sze[N];
long long n;
void dfs(long long x, long long baap) {
  sze[x] = 1;
  for (pair<long long, long long> it : v[x]) {
    if (it.first != baap) {
      dfs(it.first, x);
      sze[x] += sze[it.first];
      long long rt = sze[it.first], lf = n - sze[it.first];
      B += it.second * min(rt, lf);
      G += (it.second) * (lf % 2);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  op();
  long long t;
  cin >> t;
  while (t--) {
    long long k;
    cin >> k;
    n = 2 * k;
    for (long long i = 0; i <= n; i++) {
      v[i].clear();
      sze[i] = 0;
    }
    for (long long i = 0; i < 2 * k - 1; i++) {
      long long x, y, c;
      cin >> x >> y >> c;
      v[x].push_back({y, c});
      v[y].push_back({x, c});
    }
    G = B = 0;
    dfs(1, 1);
    PV({G, B});
  }
  return 0;
}
