#include <bits/stdc++.h>
using namespace std;
void rset();
void init_test();
void solve();
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  init_test();
  return 0;
}
template <typename T>
void chmin(T& a, T b) {
  if (a > b) a = b;
}
template <typename T>
void chmax(T& a, T b) {
  if (a < b) a = b;
}
template <typename T>
void MACRO_rdv2_Init(long long n, T& t) {
  t.resize(n);
}
template <typename First, typename... Rest>
void MACRO_rdv2_Init(long long n, First& first, Rest&... rest) {
  first.resize(n);
  MACRO_rdv2_Init(n, rest...);
}
template <typename T>
void MACRO_rdv2_Scan(long long p, T& t) {
  std::cin >> t[p];
}
template <typename First, typename... Rest>
void MACRO_rdv2_Scan(long long p, First& first, Rest&... rest) {
  std::cin >> first[p];
  MACRO_rdv2_Scan(p, rest...);
}
template <typename T>
void wrv(const vector<T>& v) {
  for (long long(__ii) = (0); (__ii) < (((long long)v.size())); ++(__ii)) {
    if (__ii) cout << ' ';
    cout << v[__ii];
  }
  cout << '\n';
}
template <typename T>
void wrm(const vector<vector<T>>& v) {
  for (long long(__ii) = (0); (__ii) < (((long long)v.size())); ++(__ii)) {
    for (long long(__jj) = (0); (__jj) < (v[__ii].size()); ++(__jj)) {
      if (__jj) cout << ' ';
      cout << v[__ii][__jj];
    }
    cout << '\n';
  }
}
template <typename T>
void sc(T& x) {
  cin >> x;
}
template <typename Head, typename... Tail>
void sc(Head& head, Tail&... tail) {
  cin >> head;
  sc(tail...);
}
template <typename T>
void wr(const T& x) {
  cout << x << '\n';
}
template <typename Head, typename... Tail>
void wr(const Head& head, const Tail&... tail) {
  cout << head << ' ';
  wr(tail...);
}
template <typename T>
void wrf(const T& x) {
  cout << x << endl;
}
template <typename Head, typename... Tail>
void wrf(const Head& head, const Tail&... tail) {
  cout << head << ' ';
  wrf(tail...);
}
template <typename T>
void debug_out(const T& x) {
  cerr << x << '\n';
}
template <typename Head, typename... Tail>
void debug_out(const Head& head, const Tail&... tail) {
  cerr << head << ' ';
  debug_out(tail...);
}
template <typename... T>
void err(const T&... cod) {
  wr(cod...);
  exit(0);
}
const long long N = 2e5 + 10;
long long n, mn, mx;
map<pair<long long, long long>, long long> ma;
vector<long long> g[N];
long long second[N];
void dfs(long long u, long long p) {
  second[u] = 1;
  for (long long v : g[u]) {
    if (v == p) continue;
    dfs(v, u);
    second[u] += second[v];
  }
}
void dfs2(long long u, long long p) {
  for (long long v : g[u]) {
    if (v == p) continue;
    dfs2(v, u);
    long long x = min(second[v], 2LL * n - second[v]);
    long long z = ma[make_pair(min(u, v), max(u, v))];
    mn += (x % 2) * z;
    mx += x * z;
  }
}
void solve() {
  cin >> n;
  for (long long(i) = (0); (i) < (2 * n - 1); ++(i)) {
    long long u, v, w;
    sc(u, v, w);
    if (u > v) swap(u, v);
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
    ma[make_pair(u, v)] = w;
  }
  dfs(0, -1);
  mn = mx = 0;
  dfs2(0, -1);
  wr(mn, mx);
  ma.clear();
  for (long long(i) = (0); (i) < (2 * n); ++(i)) g[i].clear();
}
void init_test() {
  long long qq = 1;
  cin >> qq;
  while (qq--) solve();
}
