#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int M = 4e5 + 5;
struct edge {
  int from, to, next;
  long long v;
};
edge e[M];
int head[N], cnt;
void add(int from, int to, long long v) {
  cnt++;
  e[cnt].from = from;
  e[cnt].to = to;
  e[cnt].v = v;
  e[cnt].next = head[from];
  head[from] = cnt;
}
int n;
long long ans1, ans2;
int dfs(int x, int pre) {
  int re = 0;
  for (int i = head[x]; i > 0; i = e[i].next) {
    if (e[i].to == pre) continue;
    long long temp = dfs(e[i].to, x);
    re += temp;
    ans2 += min(temp, 2 * n - temp) * e[i].v;
    if (temp % 2 != 0) {
      ans1 += e[i].v;
    }
  }
  return re + 1;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= 2 * n; i++) {
      head[i] = 0;
    }
    ans1 = ans2 = cnt = 0;
    for (int i = 1; i < 2 * n; i++) {
      int from, to, v;
      scanf("%d%d%d", &from, &to, &v);
      add(from, to, v);
      add(to, from, v);
    }
    dfs(1, 0);
    printf("%lld\n", ans1);
    printf("%lld\n", ans2);
  }
}
