#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MN = 6e5 + 5;
long long T, N, a, b, t, sz[MN], A, B;
vector<pair<long long, long long> > G[MN];
string S;
void dfs(long long s, long long r) {
  sz[s] = 1;
  for (pair<long long, long long> p : G[s]) {
    if (p.first == r) continue;
    dfs(p.first, s);
    sz[s] += sz[p.first];
    if (sz[p.first] % 2) A += p.second;
    B += p.second * min(sz[p.first], 2 * N - sz[p.first]);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> T;
  while (T--) {
    cin >> N;
    for (int i = 1; i < 2 * N; i++) {
      cin >> a >> b >> t;
      G[a].emplace_back(b, t);
      G[b].emplace_back(a, t);
    }
    dfs(1, 1);
    cout << A << ' ' << B << '\n';
    A = B = 0;
    for (int i = 1; i <= 2 * N; i++) G[i].clear();
  }
}
