#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 500;
const int INF = 1e9;
int fst[N], nxt[N], mm;
struct Edge {
  int v, w;
} e[N];
void ade(int u, int v, int w) {
  e[++mm] = (Edge){v, w}, nxt[mm] = fst[u], fst[u] = mm;
}
long long f[N], sum, dep[N];
int n, root, rsize;
int siz[N];
void dfs(int u, int fa) {
  siz[u] = 1;
  f[u] = 0;
  int mx = 0;
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, u);
    siz[u] += siz[v];
    mx = max(mx, siz[v]);
    f[u] += f[v];
    if (siz[v] & 1) f[u] += e[i].w;
  }
  mx = max(mx, n - siz[u]);
  if (mx < rsize) rsize = mx, root = u;
}
void dfs2(int u, int fa) {
  sum += dep[u];
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = e[i].v;
    if (v == fa) continue;
    dep[v] = dep[u] + e[i].w;
    dfs2(v, u);
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    n *= 2;
    for (int i = 1; i <= n; i++) fst[i] = 0;
    mm = 0;
    for (int i = 1, u, v, w; i < n; i++)
      scanf("%d%d%d", &u, &v, &w), ade(u, v, w), ade(v, u, w);
    root = 0, rsize = INF;
    dfs(1, 0);
    dep[root] = 0;
    sum = 0;
    dfs2(root, 0);
    printf("%lld ", f[1]);
    printf("%lld\n", sum);
  }
}
