#include <bits/stdc++.h>
using namespace std;
int T, n;
long long G, B;
int sz[200005];
vector<pair<int, int> > ke[200005];
void DFSMAX(int u, int pa) {
  sz[u] = 1;
  for (auto t : ke[u]) {
    int v = t.first;
    int w = t.second;
    if (v != pa) {
      DFSMAX(v, u);
      B += 1LL * w * min(sz[v], 2 * n - sz[v]);
      sz[u] += sz[v];
    }
  }
}
void DFSMIN(int u, int pa) {
  sz[u] = 1;
  for (auto t : ke[u]) {
    int v = t.first;
    int w = t.second;
    if (v != pa) {
      DFSMIN(v, u);
      G += 1LL * w * (sz[v] % 2);
      sz[u] += sz[v];
    }
  }
}
void del() {
  B = G = 0;
  for (int i = 1; i <= 2 * n; i++) ke[i].clear();
  memset(sz, 0, sizeof(sz));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= 2 * n - 1; i++) {
      int u, v, k;
      cin >> u >> v >> k;
      ke[u].push_back({v, k});
      ke[v].push_back({u, k});
    }
    DFSMAX(1, 0);
    memset(sz, 0, sizeof(sz));
    DFSMIN(1, 0);
    cout << G << " " << B << endl;
    del();
  }
}
