#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 2e5 + 15;
long long n, good, bad, sz[MAXN];
vector<pair<long long, long long> > g[MAXN];
long long dfs_good(long long v, long long pa) {
  long long t = 1;
  sz[v] = 1;
  for (auto it : g[v])
    if (it.first != pa) {
      long long x = dfs_good(it.first, v);
      sz[v] += sz[it.first];
      good += it.second * x;
      t += x;
    }
  return t & 1;
}
void dfs_bad(long long v, long long pa) {
  for (auto it : g[v])
    if (it.first != pa) {
      bad += min(sz[it.first], n - sz[it.first]) * it.second;
      dfs_bad(it.first, v);
    }
}
long long solve_good() {
  dfs_good(0, -1);
  return good;
}
long long solve_bad() {
  dfs_bad(0, -1);
  return bad;
}
void get_input() {
  good = bad = 0;
  cin >> n;
  n *= 2;
  for (long long i = 0, ggdem = n; i < ggdem; i++) g[i].clear();
  fill(sz, sz + n, 0);
  for (long long i = 1, ggdem = n; i < ggdem; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    g[x].push_back({y, z});
    g[y].push_back({x, z});
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    get_input();
    long long a = solve_good();
    long long b = solve_bad();
    cout << a << " " << b << "\n";
  }
}
