#include <bits/stdc++.h>
using namespace std;
long long w[1010000], g = 0, b = 0, k;
vector<pair<long long, long long> > v[1010000];
long long dfs(long long p, long long ind, long long s) {
  long long res = 1;
  for (long long i = 0; i < v[s].size(); i++)
    if (v[s][i].second != p) res += dfs(s, v[s][i].first, v[s][i].second);
  if (res % 2) g += w[ind];
  b += w[ind] * min(res, 2 * k - res);
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    cin >> k;
    g = 0;
    b = 0;
    for (long long i = 1; i <= 2 * k - 1; i++) {
      long long x, y;
      cin >> x >> y >> w[i];
      v[x].push_back(make_pair(i, y));
      v[y].push_back(make_pair(i, x));
    }
    dfs(0, 0, 1);
    cout << g << " " << b << endl;
    for (int i = 1; i <= 2 * k; i++) v[i].clear();
  }
  return 0;
}
