#include <bits/stdc++.h>
using namespace std;
vector<long long> v[200005];
vector<long long> v1;
long long n;
long long arr[200005];
long long a1, b1;
long long dfs(long long a, long long par) {
  long long k = 1;
  for (int i = 0; i < v[a].size(); i++) {
    if (v[a][i] != par) {
      k += dfs(v[a][i], a);
    }
  }
  arr[a] = k;
  return k;
}
void dfs2(long long a, long long par) {
  bool ab = true;
  for (int i = 0; i < v[a].size(); i++) {
    if (v[a][i] != par) {
      dfs2(v[a][i], a);
      ab = false;
    }
  }
  if (ab) {
    a1 = a;
    b1 = par;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      v[i].clear();
    }
    for (int i = 0; i < n - 1; i++) {
      long long a, b;
      cin >> a >> b;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    long long x = dfs(1, -1);
    long long a = -1;
    long long b = -1;
    long long y = n - 1;
    if (n % 2 == 0) {
      x = n / 2;
      for (int i = 1; i <= n; i++) {
        if (arr[i] == x) {
          a = i;
        }
      }
      if (a != -1) {
        for (int i = 0; i < v[a].size(); i++) {
          b = dfs(v[a][i], a);
          if (b == x) {
            b = v[a][i];
            break;
          } else {
            b = -1;
          }
        }
      }
      if (a == -1 || b == -1) {
        cout << 1 << " " << v[1][0] << "\n";
        cout << 1 << " " << v[1][0] << "\n";
      } else {
        dfs2(b, a);
        cout << b1 << " " << a1 << "\n";
        cout << a1 << " " << a << "\n";
      }
    } else {
      cout << 1 << " " << v[1][0] << "\n";
      cout << 1 << " " << v[1][0] << "\n";
    }
  }
  return 0;
}
