#include <bits/stdc++.h>
using namespace std;
struct ji {
  int nex, to, len;
} edge[200005 << 1];
int t, n, x, y, z, E, head[200005];
long long ans1, ans2;
void add(int x, int y, int z) {
  edge[E].nex = head[x];
  edge[E].to = y;
  edge[E].len = z;
  head[x] = E++;
}
int dfs(int k, int fa) {
  int sz = 1, s;
  for (int i = head[k]; i != -1; i = edge[i].nex)
    if (edge[i].to != fa) {
      s = dfs(edge[i].to, k);
      if (s & 1) ans1 += edge[i].len;
      ans2 += 1LL * min(n - s, s) * edge[i].len;
      sz += s;
    }
  return sz;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    n *= 2;
    for (int i = 1; i <= n; i++) head[i] = -1;
    E = ans1 = ans2 = 0;
    for (int i = 1; i < n; i++) {
      scanf("%d%d%d", &x, &y, &z);
      add(x, y, z);
      add(y, x, z);
    }
    dfs(1, 0);
    printf("%lld %lld\n", ans1, ans2);
  }
}
