#include <bits/stdc++.h>
using namespace std;
const long long maxn = 6e5 + 10;
long long t, k;
vector<pair<long long, long long>> adj[maxn];
pair<long long, long long> ans[510];
long long sub[maxn];
void in();
void solve();
void out();
pair<pair<long long, long long>, pair<long long, long long>> dfs(
    long long u, long long fat = -1, long long t = 0);
int main() {
  in();
  solve();
  out();
}
void in() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> t;
}
void solve() {
  for (long long T = 0; T < t; T++) {
    cin >> k;
    for (long long i = 0; i < 2 * k; i++) adj[i].clear();
    for (long long i = 1; i < 2 * k; i++) {
      long long u, v, t;
      cin >> u >> v >> t;
      u--;
      v--;
      adj[u].push_back({v, t});
      adj[v].push_back({u, t});
    }
    ans[T] = dfs(0).first;
  }
}
void out() {
  for (long long i = 0; i < t; i++)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
}
pair<pair<long long, long long>, pair<long long, long long>> dfs(long long u,
                                                                 long long fat,
                                                                 long long t) {
  sub[u] = 1;
  pair<long long, long long> bargasht = {0, 0};
  pair<long long, long long> anses = {0, 0};
  for (auto v : adj[u])
    if (v.first != fat) {
      auto x = dfs(v.first, u, v.second);
      sub[u] += sub[v.first];
      bargasht.first += x.second.first;
      bargasht.second += x.second.second;
      anses.first += x.first.first;
      anses.second += x.first.second;
    }
  if (bargasht.first % 2 == 0) {
    bargasht.first = 1;
    anses.first += t;
  } else
    bargasht.first = 0;
  if (bargasht.second == 0)
    anses.second += t * ++bargasht.second;
  else {
    bargasht.second++;
    bargasht.second = min(bargasht.second, 2 * k - sub[u]);
    anses.second += t * bargasht.second;
  }
  return {anses, bargasht};
}
