#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
vector<pair<int, int>> e[N];
long long ans1, ans2;
int siz[N], k;
void dfs(int x, int fa) {
  siz[x] = 1;
  for (auto &v : e[x]) {
    int to = v.first, t = v.second;
    if (to != fa) {
      dfs(to, x);
      siz[x] += siz[to];
      ans1 += (siz[to] & 1) * t;
      ans2 += 1ll * min(siz[to], 2 * k - siz[to]) * t;
    }
  }
}
int main() {
  int cas;
  cin >> cas;
  while (cas--) {
    cin >> k;
    int u, v, t;
    ans1 = ans2 = 0;
    for (int i = 1; i <= 2 * k; i++) e[i].clear();
    for (int i = 1; i < 2 * k; i++) {
      scanf("%d%d%d", &u, &v, &t);
      e[u].push_back(make_pair(v, t));
      e[v].push_back(make_pair(u, t));
    }
    dfs(1, 0);
    printf("%lld %lld\n", ans1, ans2);
  }
}
