#include <bits/stdc++.h>   template <typename T>   void MACRO_VAR_Scan(T& t) {     std::cin >> t;   }   template <typename First, typename... Rest>   void MACRO_VAR_Scan(First& first, Rest&... rest) {     std::cin >> first;     MACRO_VAR_Scan(rest...);   }   template <typename T>   void MACRO_VEC_ROW_Init(int n, T& t) {     t.resize(n);   }   template <typename First, typename... Rest>   void MACRO_VEC_ROW_Init(int n, First& first, Rest&... rest) {     first.resize(n);     MACRO_VEC_ROW_Init(n, rest...);   }   template <typename T>   void MACRO_VEC_ROW_Scan(int p, T& t) {     std::cin >> t[p];   }   template <typename First, typename... Rest>   void MACRO_VEC_ROW_Scan(int p, First& first, Rest&... rest) {     std::cin >> first[p];     MACRO_VEC_ROW_Scan(p, rest...);   }   template <class T>   inline T CHMAX(T& a, const T b) {     return a = (a < b) ? b : a;   }   template <class T>   inline T CHMIN(T& a, const T b) {     return a = (a > b) ? b : a;   }   template <class T>   std::vector<std::vector<T>> VV(int n, int m, T init = T()) {     return std::vector<std::vector<T>>(n, std::vector<T>(m, init));   }   template <typename S, typename T>   std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) {     os <<  (  << p.first <<  ,   << p.second <<  ) ;     return os;   }   using ll = long long;   using ull = unsigned long long;   using ld = long double;   using PAIR = std::pair<ll, ll>;   using PAIRLL = std::pair<ll, ll>;   constexpr ll INFINT = 1 << 30;   constexpr ll INFINT_LIM = (1LL << 31) - 1;   constexpr ll INFLL = 1LL << 60;   constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);   constexpr double EPS = 1e-10;   constexpr ll MOD = 998244353;   constexpr double PI = 3.141592653589793238462643383279;   template <class T, size_t N>   void FILL(T (&a)[N], const T& val) {     for (auto& x : a) x = val;   }   template <class ARY, size_t N, size_t M, class T>   void FILL(ARY (&a)[N][M], const T& val) {     for (auto& b : a) FILL(b, val);   }   template <class T>   void FILL(std::vector<T>& a, const T& val) {     for (auto& x : a) x = val;   }   template <class ARY, class T>   void FILL(std::vector<std::vector<ARY>>& a, const T& val) {     for (auto& b : a) FILL(b, val);   }   std::vector<bool> banned;   std::vector<ll> pairSum;   std::vector<ll> getDiameterPath(const std::vector<std::vector<ll>>& g) {     size_t n = g.size();     std::vector<ll> depth(n), depth2(n);     ll maxDepth = 0, farthest = -1;     std::function<void(std::vector<ll>&, ll, ll)> getDepth =         [&](std::vector<ll>& d, ll v, ll par) {           if (par == -1) {             for (size_t i = 0; i < n; ++i) d[i] = n;             d[v] = 0;             maxDepth = 0, farthest = v;           }           for (auto&& to : g[v])             if (to != par && !banned[to]) {               d[to] = d[v] + 1;               if (PAIR(maxDepth, pairSum[farthest]) < PAIR(d[to], pairSum[to])) {                 maxDepth = d[farthest = to];               }               getDepth(d, to, v);             }         };     ll start = -1;     for (ll i = 0; i < ll(n); ++i)       if (!banned[i]) start = i;     getDepth(depth, start, -1);     getDepth(depth, farthest, -1);     getDepth(depth2, farthest, -1);     const ll R = (maxDepth + 1) / 2;     for (ll i = 0; i < ll(n); ++i) {       if (banned[i]) continue;       if (depth[i] <= R && depth2[i] <= R) {         getDepth(depth, i, -1);         getDepth(depth, farthest, -1);         break;       }     }     std::vector<ll> res(maxDepth + 1);     size_t now = farthest;     while (depth[now] != 0) {       res[depth[now]] = now;       for (auto&& to : g[now])         if (depth[to] + 1 == depth[now]) {           now = to;           break;         }     }     res[depth[now]] = now;     return res;   }   signed main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     ;     ll n;     MACRO_VAR_Scan(n);     ;     std::vector<ll> a, b;     MACRO_VEC_ROW_Init(n - 1, a, b);     for (ll w = 0; w < n - 1; ++w) {       MACRO_VEC_ROW_Scan(w, a, b);     };     std::vector<std::vector<ll>> g(n);     for (ll i = 0; i < ll(n - 1); ++i) {       --a[i];       --b[i];       g[a[i]].emplace_back(b[i]);       g[b[i]].emplace_back(a[i]);     }     std::vector<bool> checked(n, false);     for (ll i = 0; i < ll(n); ++i) {       if (g[i].size() >= 3) checked[i] = true;     }     banned = checked;     {       std::vector<bool> deleted(n, false);       std::vector<ll> in(n, 0);       std::queue<ll> que;       for (ll i = 0; i < ll(n); ++i) {         in[i] = g[i].size();         if (g[i].size() == 1) que.push(i), deleted[i] = true;       }       while (!que.empty()) {         ll now = que.front();         que.pop();         for (auto& to : g[now])           if (!banned[to] && !deleted[to]) {             deleted[to] = true;             if (--in[to] <= 1) que.push(to);           }       }       for (ll i = 0; i < ll(n); ++i) banned[i] = !deleted[i];     }     std::vector<ll> depth(n, INFINT);     auto getP = [&](ll start) {       std::vector<PAIR> v;       for (auto& to : g[start])         if (!banned[to]) {           ll dist = 1;           ll pre = start;           ll now = to;           while (true) {             bool ch = false;             for (auto& ne : g[now])               if (ne != pre) {                 ++dist;                 ch = true;                 pre = now;                 now = ne;                 break;               }             if (!ch) break;           }           v.emplace_back(dist, now);         }       std::sort((v).begin(), (v).end());       std::reverse((v).begin(), (v).end());       return std::vector<PAIR>({v[0], v[1]});     };     pairSum.resize(n, 0);     for (ll i = 0; i < ll(n); ++i) {       if (!banned[i]) continue;       ll cnt = 0;       for (auto& to : g[i])         if (banned[to]) ++cnt;       if (cnt == 1) {         auto pp = getP(i);         pairSum[i] = pp[0].first + pp[1].first;       }     }     for (ll i = 0; i < ll(n); ++i) banned[i] = !banned[i];     auto path = getDiameterPath(g);     for (ll i = 0; i < ll(n); ++i) banned[i] = !banned[i];     auto pa(getP(path.front()));     auto pb(getP(path.back()));     std::cout << (pa[0].second + 1);     std::cout <<    ;     std::cout << (pb[0].second + 1);     std::cout <<   n ;     ;     std::cout << (pa[1].second + 1);     std::cout <<    ;     std::cout << (pb[1].second + 1);     std::cout <<   n ;     ;     return 0;   }