#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897923846;
const long long int MOD = 1000000007;
const long long int N = 998244353;
long long int power(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
long long int modinverse(long long int a) { return power(a, MOD - 2); }
long long int n;
vector<vector<long long int> > adj;
vector<long long int> centroid;
vector<long long int> sz;
long long int dfs(long long int node, long long int parent) {
  long long int nas = 1;
  bool dike = true;
  for (auto x : adj[node]) {
    if (x != parent) {
      nas += dfs(x, node);
      if (sz[x] > n / 2) dike = false;
    }
  }
  sz[node] = nas;
  if (n - sz[node] > n / 2) dike = false;
  if (dike) centroid.push_back(node);
  return nas;
}
void solve() {
  cin >> n;
  centroid.clear();
  sz.clear();
  sz.resize(n);
  adj.clear();
  adj.resize(n);
  long long int u, v;
  for (long long int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v), adj[v].push_back(u);
  }
  dfs(0, -1);
  if (centroid.size() == 1) {
    cout << u + 1 << ' ' << v + 1 << endl;
    cout << u + 1 << ' ' << v + 1 << endl;
  } else {
    long long int f = centroid[0], s = centroid[1];
    for (auto x : adj[f]) {
      if (x != s) {
        cout << f + 1 << ' ' << x + 1 << endl;
        cout << s + 1 << ' ' << x + 1 << endl;
        return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
