#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P) {
  in >> P.first >> P.second;
  return in;
}
template <class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P) {
  out << "(" << P.first << ", " << P.second << ")";
  return out;
}
template <class T>
istream &operator>>(istream &in, vector<T> &arr) {
  for (auto &x : arr) in >> x;
  return in;
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &arr) {
  for (auto &x : arr) out << x << ' ';
  cout << "\n";
  return out;
}
template <class T>
istream &operator>>(istream &in, deque<T> &arr) {
  for (auto &x : arr) in >> x;
  return in;
}
template <class T>
ostream &operator<<(ostream &out, const deque<T> &arr) {
  for (auto &x : arr) out << x << ' ';
  cout << "\n";
  return out;
}
int n;
vector<pair<long long, long long> > adj[500005];
int lca[22][500005];
long long d[500005];
long long in[5000005], tin = 0;
long long sz[5000005];
vector<int> picked;
long long dp[5000005];
long long G = 0;
void dfs(int x, int p = -1, long long aresta = -1) {
  for (int j = 1; j < 22; j++) {
    if (lca[j - 1][x] != -1) lca[j][x] = lca[j - 1][lca[j - 1][x]];
  }
  sz[x] = 1;
  in[x] = ++tin;
  for (auto w : adj[x]) {
    if (w.first == p) continue;
    lca[0][w.first] = x;
    d[w.first] = d[x] + w.second;
    dp[w.first] = dp[x] + 1;
    dfs(w.first, x, w.second);
    sz[x] += sz[w.first];
  }
  if (sz[x] % 2) G += aresta;
}
int getlca(int x, int y) {
  if (dp[x] < dp[y]) swap(x, y);
  for (int j = 21; j >= 0; j--) {
    if (dp[x] - (1 << j) >= dp[y]) x = lca[j][x];
  }
  if (x == y) return x;
  for (int j = 21; j >= 0; j--) {
    if (lca[j][x] != lca[j][y]) x = lca[j][x], y = lca[j][y];
  }
  return lca[0][x];
}
void fakemain() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    G = 0;
    tin = 0;
    for (int j = 0; j < (22); ++j) {
      for (int i = 0; i < (2 * n + 1); ++i)
        lca[j][i] = -1, d[i] = 0, adj[i].clear(), dp[i] = 0;
    }
    for (int i = 0; i < (2 * n - 1); ++i) {
      int x, y, z;
      cin >> x >> y >> z;
      adj[x].push_back(pair<long long, long long>(y, z));
      adj[y].push_back(pair<long long, long long>(x, z));
    }
    dfs(1);
    vector<int> v(2 * n);
    for (int i = 1; i < (2 * n + 1); ++i) v[i - 1] = i;
    sort(begin(v), end(v), [&](int a, int b) { return in[a] < in[b]; });
    long long B = 0;
    long long G2 = 0;
    for (int i = 0; i < (n); ++i) {
      B = (B + d[v[i]] + d[v[i + n]] - 2 * d[getlca(v[i], v[i + n])]);
    }
    cout << G << " " << B << endl;
  }
}
int main() { fakemain(); }
