#include <bits/stdc++.h>
using namespace std;
int n;
int info[200005], sz[200005], Prev[200005 << 1], to[200005 << 1],
    cst[200005 << 1], cnt_e;
void Node(int u, int v, int c) {
  Prev[++cnt_e] = info[u], info[u] = cnt_e, to[cnt_e] = v, cst[cnt_e] = c;
}
long long G, B;
void dfs(int u, int ff) {
  sz[u] = 1;
  for (int i = info[u], v; i; i = Prev[i])
    if ((v = to[i]) != ff) {
      dfs(v, u), sz[u] += sz[v];
      G += (sz[v] & 1) * cst[i], B += 1ll * cst[i] * min(sz[v], 2 * n - sz[v]);
    }
}
int main() {
  int T;
  scanf("%d", &T);
  for (; T--;) {
    scanf("%d", &n);
    for (int i = 1, u, v, c; i < 2 * n; i++)
      scanf("%d%d%d", &u, &v, &c), Node(u, v, c), Node(v, u, c);
    B = G = 0, dfs(1, 0);
    for (int i = 1; i <= 2 * n; i++) info[i] = 0;
    cnt_e = 0;
    printf("%lld %lld\n", G, B);
  }
}
