#include <bits/stdc++.h>
using namespace std;
const int N = 200050;
int son[N], dep[N];
struct edge {
  int v, nxt;
  long long w;
} e[N << 1];
int head[N], ecnt, du[N];
int n, m;
long long G, B;
inline void ad(int u, int v, long long w) {
  e[++ecnt].v = v;
  e[ecnt].w = w;
  e[ecnt].nxt = head[u];
  head[u] = ecnt;
  du[v]++;
}
void dfs1(int u, int fa) {
  son[u] = 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dep[v] = dep[u] + 1;
    dfs1(v, u);
    son[u] += son[v];
  }
}
void dfs2(int u, int fa) {
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs2(v, u);
    long long L = son[v];
    long long R = n - son[v];
    long long T = min(L, R);
    B += T * (long long)e[i].w;
  }
}
int dfs3(int u, int fa) {
  int num = 0;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    int p = dfs3(v, u);
    num += p;
    G += (long long)p * (long long)e[i].w;
  }
  if (du[u] == 1 || num % 2 == 0)
    return 1;
  else
    return 0;
}
int main() {
  int Test;
  scanf("%d", &Test);
  while (Test--) {
    scanf("%d", &n);
    n *= 2;
    G = B = 0;
    memset(head, 0, (n + 10) * sizeof(int));
    ecnt = 0;
    memset(son, 0, (n + 10) * sizeof(int));
    memset(dep, 0, (n + 10) * sizeof(int));
    memset(du, 0, (n + 10) * sizeof(int));
    dep[1] = 1;
    for (int i = 1; i < n; ++i) {
      int x, y;
      long long w;
      scanf("%d%d%lld", &x, &y, &w);
      ad(x, y, w), ad(y, x, w);
    }
    dfs1(1, 0);
    dfs2(1, 0);
    dfs3(1, 0);
    printf("%lld ", G);
    printf("%lld\n", B);
  }
  return 0;
}
