#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int sub[200009], n;
vector<pair<int, int> > adj[200009];
long long a, b;
void dfs(int nd, int pr) {
  sub[nd] = 1;
  for (__typeof((adj[nd]).begin()) it = (adj[nd]).begin();
       it != (adj[nd]).end(); it++)
    if (it->first != pr) {
      dfs(it->first, nd);
      sub[nd] += sub[it->first];
    }
}
void f1(int nd, int pr) {
  for (__typeof((adj[nd]).begin()) it = (adj[nd]).begin();
       it != (adj[nd]).end(); it++)
    if (it->first != pr) {
      f1(it->first, nd);
      if (sub[it->first] & 1) a += it->second;
    }
}
void f2(int nd, int pr) {
  for (__typeof((adj[nd]).begin()) it = (adj[nd]).begin();
       it != (adj[nd]).end(); it++)
    if (it->first != pr) {
      f2(it->first, nd);
      b += min(sub[it->first], 2 * n - sub[it->first]) * 1LL * (it->second);
    }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    a = b = 0;
    scanf("%d", &n);
    for (int i = 0; i < 2 * n - 1; i++) {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      adj[u].push_back(make_pair(v, w));
      adj[v].push_back(make_pair(u, w));
    }
    dfs(1, -1);
    f1(1, -1);
    f2(1, -1);
    printf("%lld %lld\n", a, b);
    for (int i = 1; i <= 2 * n; i++) adj[i].clear();
  }
  return 0;
}
