#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const int xn = 3e5 + 10;
const int xk = 1e2 + 10;
long long n, s[xn], mn, mx;
vector<pair<int, int> > adj[xn];
bool mark[xn];
void DFS(int v, int w) {
  mark[v] = true;
  s[v] = 1;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first;
    if (mark[u]) continue;
    DFS(u, adj[v][i].second);
    s[v] += s[u];
  }
  if (s[v] % 2) mn += w;
  mx += w * min(s[v], 2 * n - s[v]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int qq;
  cin >> qq;
  while (qq--) {
    cin >> n;
    mn = 0, mx = 0;
    for (int i = 0; i <= 2 * n; i++) mark[i] = 0, adj[i].resize(0);
    long long x, y, z;
    for (int i = 0; i < 2 * n - 1; i++)
      cin >> x >> y >> z, adj[x].push_back({y, z}), adj[y].push_back({x, z});
    DFS(1, 0);
    cout << mn << ' ' << mx << '\n';
  }
  return 0;
}
