#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b, long long int m) {
  long long int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
vector<pair<long long int, long long int> > v[200009];
long long int sz[200009];
long long int k;
long long int small = 0, big = 0;
void dfs(long long int num, long long int par) {
  for (auto it : v[num]) {
    if (it.first == par) continue;
    dfs(it.first, num);
    sz[num] += sz[it.first];
  }
}
void dfs1(long long int num, long long int par) {
  for (auto it : v[num]) {
    if (it.first == par) continue;
    long long int a = sz[it.first];
    long long int b = 2 * k - a;
    big += (it.second) * (min(a, b));
    small += (it.second) * (a & 1);
    dfs1(it.first, num);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    cin >> k;
    small = 0, big = 0;
    for (long long int i = 1; i < k + k + 1; i++) {
      v[i].clear();
      sz[i] = 1;
    }
    for (long long int i = 1; i < k + k; i++) {
      long long int l, r;
      cin >> l >> r;
      long long int d;
      cin >> d;
      v[l].push_back({r, d});
      v[r].push_back({l, d});
    }
    dfs(1, 0);
    dfs1(1, 0);
    cout << small << " " << big << endl;
  }
}
