#include <bits/stdc++.h>
using namespace std;
std::vector<long long int> adj[100001];
long long int sl[100001];
long long int n;
long long int dfs(long long int u, long long int p) {
  long long int sum = 1, ma = 0;
  for (auto y : adj[u]) {
    if (y == p) continue;
    long long int val = dfs(y, u);
    if (val > ma) {
      ma = val;
    }
    sum += val;
  }
  ma = max(ma, n - sum);
  sl[u] = ma;
  return sum;
}
void solve() {
  long long int i, x, y, first, min;
  cin >> n;
  for (i = 0; i < n; i++) {
    adj[i].clear();
    sl[i] = -1;
  }
  for (i = 0; i < n - 1; i++) {
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(0, -1);
  min = sl[0];
  first = 1;
  for (i = 1; i < n; i++) {
    if (sl[i] < min) {
      min = sl[i];
      first = 1;
    } else if (min == sl[i]) {
      first++;
    }
  }
  if (first == 1) {
    cout << x + 1 << " " << y + 1 << endl;
    cout << x + 1 << " " << y + 1 << endl;
  } else {
    first = 0;
    for (i = 0; i < n && first < 2; i++) {
      if (sl[i] == min) {
        if (first == 0) {
          x = i;
          first = 1;
        } else {
          y = i;
          first = 2;
        }
      }
    }
    first = (adj[x][0] == y) ? adj[x][1] : adj[x][0];
    cout << x + 1 << " " << first + 1 << endl;
    cout << first + 1 << " " << y + 1 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
