#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long a[N], ch[N], p[N];
bool vis[N], vis1[N];
vector<long long> v[N];
set<int> s;
map<string, long long> mp;
int node1 = 1, node2 = 1, mx = 0, n;
bool q = 0;
int dfs(int j, int r) {
  for (int i = 0; i < v[j].size(); i++) {
    if (v[j][i] != r) p[v[j][i]] = j, ch[j] += dfs(v[j][i], j);
  }
  if (ch[j] == n / 2) node1 = j, node2 = r;
  return ch[j];
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int x, y;
    cin >> n;
    v[1].clear(), ch[1] = 0, node1 = 1, node2 = 1, mx = 0;
    for (int i = 2; i <= n; i++) v[i].clear(), ch[i] = 1;
    for (int i = 0; i < n - 1; i++) {
      cin >> x >> y;
      v[y].push_back(x), v[x].push_back(y);
    }
    if (n % 2) {
      cout << node1 << " " << v[node1][0] << "\n"
           << node2 << " " << v[node1][0] << "\n";
      continue;
    }
    dfs(1, 0);
    for (int i = 0; i < v[node1].size(); i++) {
      if (node2 != v[node1][i]) {
        cout << node1 << " " << v[node1][i] << "\n"
             << node2 << " " << v[node1][i] << "\n";
        break;
      }
    }
  }
}
