#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
int head[N + 5], nxt[N * 2 + 5], to[N * 2 + 5], tot;
long long val[N * 2 + 5];
inline void init(int n) {
  tot = -1;
  memset(head, -1, (n + 4) * sizeof(int));
}
inline void addedge(int u, int v, int w) {
  nxt[++tot] = head[u];
  to[head[u] = tot] = v;
  val[tot] = w;
}
int rt, k, n;
long long G, B;
int dfs1(int u, int fa) {
  int cnt = 1, maxx = 0;
  for (int e = head[u]; ~e; e = nxt[e]) {
    int v = to[e];
    if (v != fa) {
      int tmp = dfs1(v, u);
      maxx = max(maxx, tmp);
      cnt += tmp;
    }
  }
  if (maxx <= k && n - cnt <= k) rt = u;
  return cnt;
}
int dfs2(int u, int fa) {
  int cnt = 1;
  for (int e = head[u]; ~e; e = nxt[e]) {
    int v = to[e];
    if (v != fa) {
      int tmp = dfs2(v, u);
      if (tmp & 1) G += val[e];
      B += val[e] * tmp;
      cnt += tmp;
    }
  }
  return cnt;
}
int main() {
  int T, r, c;
  scanf("%d", &T);
  while (T--) {
    int u, v, w;
    scanf("%d", &k);
    init(n = 2 * k);
    for (int i = 1; i <= n - 1; ++i) {
      scanf("%d %d %d", &u, &v, &w);
      addedge(u, v, w);
      addedge(v, u, w);
    }
    G = 0, B = 0;
    dfs1(1, 0);
    dfs2(rt, 0);
    printf("%lld %lld\n", G, B);
  }
  return 0;
}
