#include <bits/stdc++.h>
using namespace std;
int n;
map<int, int> M[200005];
vector<int> dsk[200005];
long long G, B;
int f[200005];
void dfs(int u, int p) {
  f[u] = 1;
  for (int v : dsk[u]) {
    if (v == p) continue;
    dfs(v, u);
    f[u] += f[v];
  }
  B += 1ll * M[u][p] * (min(f[u], n - f[u]));
  if (f[u] & 1) G += M[u][p];
}
void doing() {
  G = 0;
  B = 0;
  cin >> n;
  n *= 2;
  for (int i = 1; i <= n; i++) dsk[i].clear();
  for (int i = 1; i <= n - 1; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    dsk[x].push_back(y);
    dsk[y].push_back(x);
    M[x][y] = M[y][x] = z;
  }
  dfs(1, 0);
  cout << G << ' ' << B << "\n";
}
int main() {
  int T;
  cin >> T;
  while (T--) doing();
}
