func_code_string: #include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     x = 0;     int f = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) f = -f;     for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);     x *= f;   }   inline void print(int x) {     if (x < 0) putchar( - ), x = -x;     if (!x) return;     print(x / 10), putchar((x % 10) ^ 48);   }   inline void write(int x) {     if (!x)       putchar( 0 );     else       print(x);     putchar(  n );   }   int n, ans[5], head[1000050], tot, mx[1000050], mx1[1000050], p, dep[1000050],       d, vis[1000050], f[1000050];   struct edge {     int to, nxt;   } e[1000050 << 1];   void ins(int u, int v) { e[++tot] = (edge){v, head[u]}, head[u] = tot; }   void dfs(int x, int fa) {     dep[x] = dep[fa] + 1;     int cnt = 0;     f[x] = fa;     for (int i = head[x]; i; i = e[i].nxt)       if (e[i].to != fa && !vis[e[i].to]) {         dfs(e[i].to, x), cnt++;         if (!mx[x] || dep[mx[x]] < dep[mx[e[i].to]])           mx1[x] = mx[x], mx[x] = mx[e[i].to];         else if (dep[mx[e[i].to]] > dep[mx1[x]])           mx1[x] = mx[e[i].to];       }     if (!cnt) mx[x] = x;     if (cnt >= 2) {       if (dep[x] > d)         d = dep[x], p = x;       else if (dep[x] == d && dep[mx1[x]] + dep[mx[x]] > dep[mx1[p]] + dep[mx[p]])         p = x;     }   }   int main() {     read(n);     for (int i = 1, x, y; i < n; i++) read(x), read(y), ins(x, y), ins(y, x);     dfs(1, 0), ans[1] = mx[p], ans[3] = mx1[p];     for (int i = head[p]; i; i = e[i].nxt)       if (e[i].to != f[p] && (mx[e[i].to] == mx[p] || mx[e[i].to] == mx1[p]))         vis[e[i].to] = 1;     memset(mx, 0, sizeof mx), memset(mx1, 0, sizeof mx1);     d = 0;     dfs(p, 0), ans[2] = mx[p], ans[4] = mx1[p];     printf( %d %d n%d %d n , ans[1], ans[2], ans[3], ans[4]);     return 0;   }   