func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 10;   int t, n, son[maxn], root, p[maxn], rt;   vector<int> g[maxn];   void dfs(int u, int fa) {     son[u] = 1;     p[u] = fa;     for (auto it : g[u]) {       if (it == fa) continue;       dfs(it, u);       son[u] += son[it];     }   }   void getroot(int u, int fa) {     root = u;     for (auto it : g[u]) {       if (it == fa) continue;       if (son[it] > n - son[it]) getroot(it, u);     }   }   int getleaf(int u, int fa) {     if (g[u].size() == 1) return u;     for (auto it : g[u]) {       if (it == fa) continue;       return getleaf(it, u);     }   }   int main() {     scanf( %d , &t);     while (t--) {       root = rt = 0;       scanf( %d , &n);       for (int i = 1; i < n; i++) {         int u, v;         scanf( %d%d , &u, &v);         g[u].push_back(v);         g[v].push_back(u);       }       dfs(1, 0);       getroot(1, 0);       for (auto it : g[root]) {         if (it != p[root] && son[it] == n - son[it]) rt = it;       }       if (!rt) {         printf( %d %d n%d %d n , root, g[root][0], root, g[root][0]);       } else {         int l = getleaf(rt, p[rt]);         printf( %d %d n%d %d n , p[l], l, root, l);       }       for (int i = 1; i <= n; i++) g[i].clear(), p[i] = 0;     }     return 0;   }   