#include <bits/stdc++.h>
using namespace std;
long long minans, maxans;
int tot;
int dfs(int from, vector<bool>& visit, const vector<int>& v,
        const vector<int>& pre, const vector<int>& t, const vector<int>& head) {
  visit[from] = true;
  int size = 1;
  for (int i = head[from]; i != -1; i = pre[i]) {
    if (visit[v[i]]) continue;
    int to = v[i], l = t[i], ssize;
    ssize = dfs(to, visit, v, pre, t, head);
    size += ssize;
    if (ssize % 2 == 1) minans += l;
    maxans += (long long)l * min(ssize, tot - ssize);
  }
  return size;
}
void work() {
  int n;
  cin >> n;
  n *= 2;
  vector<int> v(n * 2), pre(n * 2), t(n * 2), head(n, -1);
  int num = 0;
  auto ins = [&](int u, int vv, int tt) {
    v[num] = vv;
    t[num] = tt;
    pre[num] = head[u];
    head[u] = num++;
  };
  for (int i = 0; i < n - 1; ++i) {
    int uu, vv, ttt;
    cin >> uu >> vv >> ttt;
    uu--, vv--;
    ins(uu, vv, ttt);
    ins(vv, uu, ttt);
  }
  vector<bool> visit(n, false);
  minans = maxans = 0;
  tot = n;
  dfs(0, visit, v, pre, t, head);
  cout << minans << " " << maxans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) work();
}
