#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200020;
const int INF = 0x3f3f3f3f;
int head[MAXN];
long long size[MAXN];
int cnt, n, T;
long long ans1, ans2;
struct Edge {
  int to;
  long long dis;
  int nxt;
} e[MAXN << 1];
void AddEdge(int from, int to, long long dis) {
  e[++cnt].to = to;
  e[cnt].dis = dis;
  e[cnt].nxt = head[from];
  head[from] = cnt;
}
void dfs1(int u, int fa) {
  size[u] = 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs1(v, u);
    size[u] += size[v];
    if (size[v] % 2 == 1) ans1 += e[i].dis;
  }
}
void dfs2(int u, int fa) {
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs2(v, u);
    ans2 += min(size[v], (long long)2 * n - size[v]) * e[i].dis;
  }
}
long long read() {
  char c = getchar();
  long long x = 0, flag = 1;
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * flag;
}
int main() {
  scanf("%d", &T);
  while (T) {
    --T, cnt = 0, ans1 = ans2 = 0;
    scanf("%d", &n);
    for (int i = 1; i <= 2 * n; ++i) head[i] = 0, size[i] = 0;
    for (int i = 1; i < 2 * n; ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      long long w;
      cin >> w;
      AddEdge(u, v, w);
      AddEdge(v, u, w);
    }
    dfs1(1, 0);
    dfs2(1, 0);
    cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}
