#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const int N = 2e5 + 10;
const int M = 1000 + 10;
const int mod = (int)1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1.0);
struct E {
  int v, nxt, d;
} e[N << 1];
int k;
int head[N], tot;
void init() {
  tot = 0;
  memset(head, 0, sizeof(int) * (k * 2 + 5));
}
inline void add(int u, int v, int d) {
  e[++tot] = {v, head[u], d};
  head[u] = tot;
}
long long G, B;
pair<int, bool> dfs(int u, int fa) {
  int d = -1;
  int sz = 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    pair<int, bool> p = dfs(v, u);
    sz += p.first;
    B += (long long)min(p.first, 2 * k - p.first) * e[i].d;
    if (p.second) {
      if (d == -1)
        d = e[i].d;
      else {
        G += d + e[i].d;
        d = -1;
      }
    }
  }
  if (~d) G += d;
  return {sz, d == -1};
}
void work() {
  cin >> k;
  init();
  for (int i = 0; i < 2 * k - 1; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    add(x, y, z);
    add(y, x, z);
  }
  G = B = 0;
  dfs(1, -1);
  cout << G << " " << B << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) work();
  return 0;
}
