#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
inline void wri(long long x) {
  write(x);
  putchar(' ');
}
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int n, m;
int size[maxn];
long long ans1, ans2;
vector<pair<int, int> > edge[maxn];
void dfs(int u, int fa) {
  size[u] = 1;
  for (auto v : edge[u]) {
    if (v.first == fa) continue;
    dfs(v.first, u);
    size[u] += size[v.first];
    ans1 += 1ll * (size[v.first] % 2) * v.second;
    ans2 += 1ll * (min(size[v.first], n - size[v.first])) * v.second;
  }
}
void solve() {
  ans1 = ans2 = 0;
  n = read() * 2;
  for (int i = (1); i <= int(n); ++i) edge[i].clear();
  for (register int i = (1); i < int(n); ++i) {
    int x = read(), y = read(), z = read();
    edge[x].push_back({y, z});
    edge[y].push_back({x, z});
  }
  dfs(1, 0);
  wri(ans1), writeln(ans2);
}
int main() {
  int T = read();
  while (T--) solve();
  return 0;
}
