#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e5 + 10;
vector<int> g[N];
int n;
int sz[N], leaf[N], par[N];
int small = 0, big = 0;
void dfs(int v, int p) {
  sz[v] = 1;
  leaf[v] = v;
  par[v] = p;
  int maxsz = 0;
  for (auto u : g[v]) {
    if (u != p) {
      dfs(u, v);
      sz[v] += sz[u];
      leaf[v] = leaf[u];
      maxsz = max(maxsz, sz[u]);
    }
  }
  if (!small && n - sz[v] <= n / 2 && maxsz <= n / 2) small = v;
  if (n - sz[v] <= n / 2 && maxsz <= n / 2) big = v;
}
void solve() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (n & 1) {
    cout << 1 << " " << g[1][0] << '\n';
    cout << 1 << " " << g[1][0] << '\n';
    goto clean;
  }
  dfs(1, 1);
  if (small && big) {
    cout << leaf[small] << " " << par[leaf[small]] << '\n';
    cout << leaf[small] << " " << big << '\n';
  } else {
    cout << 1 << " " << g[1][0] << '\n';
    cout << 1 << " " << g[1][0] << '\n';
  }
clean:;
  for (int i = 0; i <= n; i++) {
    g[i].clear();
    sz[i] = leaf[i] = par[i] = 0;
    small = big = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
