#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e5 + 5;
int t, n, sz[N];
vector<int> g[N];
vector<int> v;
void dfs(int node, int par) {
  sz[node] = 1;
  bool c = true;
  for (auto &i : g[node])
    if (i != par) {
      dfs(i, node);
      sz[node] += sz[i];
      if (sz[i] > n / 2) c = false;
    }
  if (n - sz[node] > n / 2) c = false;
  if (c) v.push_back(node);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    v.clear();
    cin >> n;
    for (int i = 1; i <= n; i++) g[i].clear(), sz[i] = 0;
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    dfs(1, -1);
    if (v.size() == 1) {
      cout << "1 " << g[1].back() << '\n' << "1 " << g[1].back() << '\n';
      continue;
    }
    for (auto &i : g[v[0]])
      if (i != v[1]) {
        cout << v[0] << " " << i << '\n' << v[1] << " " << i << '\n';
        break;
      }
  }
  return 0;
}
