#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const int N = 1e5 + 1;
vector<int> co[N];
int sub[N], par[N];
int n;
void dfs(int x, int p) {
  sub[x] = 1;
  par[x] = p;
  for (auto y : co[x]) {
    if (y == p) continue;
    dfs(y, x);
    sub[x] += sub[y];
  }
}
bool check(int u) {
  int maxx = n - sub[u];
  for (auto x : co[u]) {
    if (x == par[u]) continue;
    maxx = max(maxx, sub[x]);
  }
  if (maxx <= n / 2) return 1;
  return 0;
}
void solve() {
  cin >> n;
  for (int i = 0; i <= n; i++) co[i].clear();
  memset(sub, 0, sizeof(sub));
  memset(par, 0, sizeof(par));
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    co[a].push_back(b);
    co[b].push_back(a);
  }
  dfs(1, 0);
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (check(i)) {
      ans.push_back(i);
    }
  }
  if ((int)(ans.size()) == 1) {
    cout << 1 << " " << co[1][0] << "\n";
    cout << 1 << " " << co[1][0];
    return;
  }
  int a = ans[0], b = ans[1];
  int maxx = 0, cur = 0;
  for (auto x : co[a]) {
    if (sub[x] >= maxx && x != b) {
      maxx = sub[x];
      cur = x;
    }
  }
  cout << cur << " " << a << "\n";
  cout << cur << " " << b;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
}
