#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> mat;
vector<int> se, parent;
pair<int, int> ham;
void dfs(int s, int par) {
  parent[s] = par;
  if (mat[s][0] == par and mat[s].size() == 1) {
    se[s] = 1;
    return;
  }
  int temp = 1;
  for (int i = 0; i <= mat[s].size() - 1; i++) {
    if (mat[s][i] == par)
      continue;
    else {
      dfs(mat[s][i], s);
      temp += se[mat[s][i]];
    }
  }
  se[s] = temp;
  return;
}
void dfs1(int s, int par) {
  if (mat[s][0] == par and mat[s].size() == 1) {
    ham = {par, s};
  }
  for (int i = 0; i <= mat[s].size() - 1; i++) {
    if (mat[s][i] == par)
      continue;
    else {
      dfs1(mat[s][i], s);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    mat = vector<vector<int>>(n);
    se = parent = vector<int>(n);
    vector<pair<int, int>> ed, pork;
    int x, y;
    for (int i = 0; i <= n - 2; i++) {
      cin >> x >> y;
      x--, y--;
      ed.push_back({x, y});
      mat[x].push_back(y);
      mat[y].push_back(x);
    }
    if (n % 2 != 0) {
      cout << ed[0].first + 1 << " " << ed[0].second + 1 << endl;
      cout << ed[0].first + 1 << " " << ed[0].second + 1 << endl;
      continue;
    }
    dfs(0, -1);
    bool flag = false;
    for (int i = 0; i <= n - 1; i++) {
      if (se[i] == n / 2) {
        dfs1(i, parent[i]);
        cout << ham.first + 1 << " " << ham.second + 1 << endl;
        cout << parent[i] + 1 << " " << ham.second + 1 << endl;
        flag = true;
        break;
      }
    }
    if (!flag) {
      cout << ed[0].first + 1 << " " << ed[0].second + 1 << endl;
      cout << ed[0].first + 1 << " " << ed[0].second + 1 << endl;
    }
  }
}
