#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, m = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') m = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * m;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    write(-x);
    return;
  }
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
inline void writesp(long long x) {
  write(x);
  putchar(' ');
}
long long n, m, x, y, _ = 0, mn = 1 << 30;
long long f[300005];
long long size[300005];
long long ans[300005];
vector<long long> G[300005];
void dfs(long long now, long long fa) {
  f[now] = fa;
  long long __ = 0;
  for (long long i = 0; i < G[now].size(); i++) {
    long long to = G[now][i];
    if (to == fa) continue;
    dfs(to, now);
    size[now] += size[to];
    __ = max(__, size[to]);
  }
  if (__ < mn) mn = __, ans[_ = 1] = now;
}
void dfs1(long long now, long long fa) {
  for (long long i = 0; i < G[now].size(); i++) {
    long long to = G[now][i];
    if (to == fa) continue;
    dfs1(to, now);
  }
  if (size[1] - size[now] == n / 2 && size[now] == n / 2)
    ans[1] = now, ans[2] = f[now], _ = 2;
}
long long T;
signed main() {
  T = read();
  while (T--) {
    n = read();
    for (long long i = 1; i <= n; i++) G[i].clear();
    _ = 0;
    mn = 1 << 30;
    for (long long i = 1; i < n; i++)
      x = read(), y = read(), G[x].push_back(y), G[y].push_back(x);
    for (long long i = 1; i <= n; i++) size[i] = 1;
    dfs(1, 0);
    dfs1(1, 0);
    if (_ == 1) {
      writesp(ans[_]);
      writeln(G[ans[_]][0]);
      writesp(ans[_]);
      writeln(G[ans[_]][0]);
    } else {
      long long X, Y = 0;
      X = G[ans[2]][0];
      if (G[ans[2]].size() > 1) Y = G[ans[2]][1];
      if (f[ans[2]])
        writesp(ans[2]), writeln(f[ans[2]]), writesp(ans[1]),
            writeln(f[ans[2]]);
      else
        writesp(ans[2]), writeln(X == ans[1] ? Y : X), writesp(ans[1]),
            writeln(X == ans[1] ? Y : X);
    }
  }
}
