#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e5 + 5;
int t, n, u, v, mn, sz[N], mx[N];
vector<int> g[N];
void dfs(int node, int parent) {
  sz[node] = 1;
  for (auto i : g[node])
    if (i != parent) dfs(i, node);
  sz[parent] += sz[node];
  for (auto i : g[node]) {
    if (i == parent) continue;
    mx[node] = max(mx[node], sz[i]);
  }
  if (node != 1) mx[node] = max(mx[node], n - sz[node]);
  mn = min(mn, mx[node]);
}
void get_centroids() {
  u = v = -1;
  for (int i = 1; i <= n; i++) {
    if (mx[i] != mn) continue;
    if (u == -1)
      u = i;
    else if (v == -1)
      v = i;
    else
      assert(!n);
  }
}
void in() {
  for (int i = 1; i <= n; i++) sz[i] = mx[i] = 0, g[i].clear();
  mn = INT_MAX;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    in();
    for (int i = 1; i < n; i++) {
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    dfs(1, 0);
    get_centroids();
    int u1, v1, u2, v2;
    if (v == -1) {
      u1 = u, v1 = g[u].front();
      u2 = u1, v2 = v1;
    } else {
      u1 = v1 = -1;
      bool ok = 0;
      for (auto i : g[u])
        if (i != v) u1 = u, v1 = i;
      if (u1 != -1) {
        u2 = v1, v2 = v;
      } else {
        for (auto i : g[v])
          if (i != u) u1 = v, v1 = i;
        u2 = u, v2 = v1;
      }
    }
    cout << u1 << ' ' << v1 << '\n';
    cout << u2 << ' ' << v2 << '\n';
  }
  return 0;
}
