#include <bits/stdc++.h>
using namespace std;
long long int vis[600005], add[600005], sub[600005], ans, ans2, n;
vector<pair<long long int, long long int>> v[600005];
void dfs(long long int node) {
  vis[node] = 1;
  for (auto it : v[node])
    if (!vis[it.first]) {
      dfs(it.first);
      add[node] += add[it.first];
      if (add[it.first]) ans = ans + it.second;
      ans2 = ans2 + min((2 * n - sub[it.first]), sub[it.first]) * it.second;
      sub[node] += sub[it.first];
    }
  ++sub[node];
  add[node] = (add[node] + 1) % 2;
}
void cl() {
  long long int i;
  for (i = 0; i < 600005; ++i) {
    vis[i] = 0;
    sub[i] = 0;
    add[i] = 0;
    v[i].clear();
  }
  ans = 0;
  ans2 = 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int i;
    cin >> n;
    for (i = 1; i < 2 * n; ++i) {
      long long int r, g, val;
      cin >> r >> g >> val;
      v[r].push_back({g, val});
      v[g].push_back({r, val});
    }
    dfs(1);
    cout << ans << " " << ans2 << "\n";
    cl();
  }
  return 0;
}
