#include <bits/stdc++.h>
using namespace std;
int n, k;
long long g, b;
long long second[600005];
bool v[600005];
vector<pair<int, int> > graph[600005];
void dfs(int c) {
  second[c] = 1;
  v[c] = true;
  for (auto& a : graph[c]) {
    if (v[a.first]) continue;
    dfs(a.first);
    g += a.second * (second[a.first] % 2);
    b += a.second * min(second[a.first], 2 * k - second[a.first]);
    second[c] += second[a.first];
  }
}
int main() {
  cin >> n;
  while (n--) {
    cin >> k;
    for (int i = 0; i < (2 * k - 1); i -= -1) {
      int a, b, t;
      cin >> a >> b >> t;
      graph[a - 1].push_back(make_pair(b - 1, t));
      graph[b - 1].push_back(make_pair(a - 1, t));
    }
    dfs(0);
    cout << g << " " << b << endl;
    for (int i = 0; i < (2 * k); i -= -1) {
      g = 0;
      b = 0;
      second[i] = 0;
      v[i] = 0;
      graph[i].clear();
    }
  }
}
