#include <bits/stdc++.h>   using namespace std;   struct elem {     int u, clen, tlen;     int nlis;     int lis[4];     elem() {       clen = -1;       nlis = 0;     }     elem(int u, int clen, int tlen) : u(u), clen(clen), tlen(tlen) { nlis = 0; }   };   void write(string s, elem e) {     cout <<  [  << s <<  , u   << e.u <<  , clen   << e.clen <<  , tlen            << e.tlen <<  , lis  ;     for (int i = 0; i < e.nlis; i++) cout << e.lis[i] <<  , ;     cout <<  ]  <<   n ;   }   void add(elem &e, int u) { e.lis[e.nlis++] = u; }   bool operator<(elem e1, elem e2) {     if (e1.clen != e2.clen) return e1.clen < e2.clen;     return e1.tlen < e2.tlen;   }   elem operator+(elem e1, elem e2) {     elem e = elem(e1.u, e1.clen + e2.clen, e1.tlen + e2.tlen);     for (int i = 0; i < e1.nlis; i++) add(e, e1.lis[i]);     for (int i = 0; i < e2.nlis; i++) add(e, e2.lis[i]);     return e;   }   void maximize(int &a, int b) { a = max(a, b); }   void maximize(elem &a, elem b) { a = max(a, b); }   const int limit = 200005;   int n;   vector<int> g[limit];   elem best1[limit];   elem best2[limit];   elem best3[limit];   elem sol;   int n1, n2, n3;   elem lis1[limit];   elem lis2[limit];   elem lis3[limit];   void compute(int u, int p) {     elem &b1 = best1[u];     elem &b2 = best2[u];     elem &b3 = best3[u];     b1 = elem(u, 0, 0);     add(b1, u);     vector<int> &ar = g[u];     for (int i = 0; i < int(ar.size()); i++) {       int v = ar[i];       if (v != p) compute(v, u);     }     n1 = n2 = n3 = 0;     for (int i = 0; i < int(ar.size()); i++) {       int v = ar[i];       if (v != p) {         lis1[n1++] = elem(v, 0, 1) + best1[v];         if (best2[v].clen != -1) lis2[n2++] = elem(v, 1, 2) + best2[v];         if (best3[v].clen != -1) lis3[n3++] = elem(v, 0, 1) + best3[v];       }     }     sort(lis1, lis1 + n1);     reverse(lis1, lis1 + n1);     sort(lis2, lis2 + n2);     reverse(lis2, lis2 + n2);     sort(lis3, lis3 + n3);     reverse(lis3, lis3 + n3);     if (n1 >= 1) {       maximize(b1, lis1[0]);     }     if (n2 >= 1) maximize(b2, lis2[0]);     if (n1 >= 2) maximize(b2, lis1[0] + lis1[1]);     if (n1 >= 3) maximize(b3, lis1[0] + lis1[1] + lis1[2]);     for (int i1 = 0; i1 < 2 and i1 < n1; i1++)       for (int i2 = 0; i2 < 2 and i2 < n2; i2++)         if (lis1[i1].u != lis2[i2].u) maximize(b3, lis2[i2] + lis1[i1]);     if (n3 >= 1) maximize(b3, lis3[0]);     if (n2 >= 2) maximize(sol, lis2[0] + lis2[1]);     if (n3 >= 1) {       elem e = lis3[0];       add(e, u);       maximize(sol, e);     }     for (int i1 = 0; i1 < 3; i1++)       for (int j1 = i1 + 1; j1 < 3 and j1 < n1; j1++)         for (int i2 = 0; i2 < 3 and i2 < n2; i2++)           if (lis1[i1].u != lis2[i2].u and lis1[j1].u != lis2[i2].u)             maximize(sol, lis1[i1] + lis1[j1] + lis2[i2]);     for (int i1 = 0; i1 < 2 and i1 < n1; i1++)       for (int i3 = 0; i3 < 2 and i3 < n3; i3++)         if (lis1[i1].u != lis3[i3].u) maximize(sol, lis3[i3] + lis1[i1]);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       g[u].push_back(v);       g[v].push_back(u);     }     compute(1, 0);     int(&lis)[4] = sol.lis;     cout << lis[0] <<     << lis[2] <<   n ;     cout << lis[1] <<     << lis[3] <<   n ;   }