#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
void dfs(int u, vector<vector<int>> &g, vector<int> &subtree,
         vector<int> &par) {
  subtree[u] = 1;
  for (auto v : g[u]) {
    if (v != par[u]) {
      par[v] = u;
      dfs(v, g, subtree, par);
      subtree[u] += subtree[v];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    n *= 2;
    vector<vector<int>> g(n);
    vector<int> subtree(n);
    vector<int> par(n);
    vector<tuple<int, int, int>> edges(n - 1);
    for (int i = 0; i < n - 1; ++i) {
      int a, b, t;
      cin >> a >> b >> t;
      --a, --b;
      g[a].push_back(b);
      g[b].push_back(a);
      edges[i] = make_tuple(a, b, t);
    }
    dfs(0, g, subtree, par);
    ll G = 0, B = 0;
    for (int i = 0; i < n - 1; ++i) {
      int a, b, t;
      tie(a, b, t) = edges[i];
      if (a != par[b]) swap(a, b);
      G += (ll)t * (subtree[b] % 2);
      B += (ll)t * min(subtree[b], n - subtree[b]);
    }
    cout << G << ' ' << B << '\n';
  }
}
