#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void amin(X& x, const Y& y) {
  if (x > y) x = y;
}
template <class X, class Y>
void amax(X& x, const Y& y) {
  if (x < y) x = y;
}
const int INF = 1e9 + 10;
const long long INFL = (long long)1e18 + 10;
const int MAX = 2e5 + 10;
int n;
vector<int> es[MAX];
int mx1[MAX];
pair<int, pair<int, int> > mx2[MAX];
int pmx[MAX];
int rshare, rlen;
pair<int, int> r1, r2;
pair<int, pair<int, int> > zero;
int limit;
int h[MAX];
int lca[22][MAX];
void visit_lca(int u, int p) {
  h[u] = h[p] + 1;
  lca[0][u] = p;
  limit = max(limit, h[u]);
  for (auto v : es[u])
    if (v != p) visit_lca(v, u);
}
void build_lca() {
  visit_lca(1, 0);
  limit = (int)log2(limit) + 1;
  for (int i = 1; i <= limit; i++)
    for (int j = 1; j <= n; j++) lca[i][j] = lca[i - 1][lca[i - 1][j]];
}
int getlca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  for (int i = limit; i >= 0; i--)
    if (h[lca[i][v]] >= h[u]) v = lca[i][v];
  if (u == v) return u;
  for (int i = limit; i >= 0; i--)
    if (lca[i][u] != lca[i][v]) {
      u = lca[i][u];
      v = lca[i][v];
    }
  return lca[0][u];
}
int getlen(int u, int v) {
  if (u == 0 || v == 0) return 0;
  int x = getlca(u, v);
  return h[u] + h[v] - 2 * h[x];
}
void check0() {
  bool has3 = false;
  for (int i = 1; i <= n; i++)
    if ((int(es[i].size())) > 2) {
      has3 = true;
      break;
    }
  if (has3) return;
  vector<int> start;
  for (int i = 1; i <= n; i++)
    if ((int(es[i].size())) == 1) start.push_back(i);
  pair<int, int> p1, p2;
  p1 = make_pair(start[0], es[start[0]][0]);
  p2.first = es[p1.second][0] == p1.first ? es[p1.second][1] : es[p1.second][0];
  p2.second = start[1];
  cout << p1.first << " " << p1.second << '\n';
  cout << p2.first << " " << p2.second << '\n';
  exit(0);
}
void check1() {
  int cnt3 = 0;
  for (int i = 1; i <= n; i++)
    if ((int(es[i].size())) > 2) cnt3++;
  if (cnt3 > 1) return;
  int start = 0;
  for (int i = 1; i <= n; i++)
    if ((int(es[i].size())) > 2) {
      start = i;
      break;
    }
  vector<pair<int, int> > end;
  for (auto u : es[start]) {
    int x = u;
    int last = start;
    while ((int(es[u].size())) > 1) {
      int v = es[u][0] == last ? es[u][1] : es[u][0];
      last = u;
      u = v;
    }
    end.push_back(make_pair(u, getlen(x, u)));
  }
  if ((int(es[start].size())) == 3) {
    cout << end[0].first << " " << end[1].first << '\n';
    cout << es[start][2] << " " << end[2].first << '\n';
  } else {
    sort(end.begin(), end.end(),
         [](const pair<int, int>& ls, const pair<int, int>& rs) {
           return ls.second > rs.second;
         });
    cout << end[0].first << " " << end[1].first << '\n';
    cout << end[2].first << " " << end[3].first << '\n';
  }
  exit(0);
}
bool comp(int u, const pair<int, pair<int, int> >& ls,
          const pair<int, pair<int, int> >& rs) {
  if (ls.first != rs.first) return ls.first < rs.first;
  return getlen(u, ls.second.first) + getlen(u, ls.second.second) <=
         getlen(u, rs.second.first) + getlen(u, rs.second.second);
}
void visit1(int u, int p) {
  for (auto v : es[u])
    if (v != p) visit1(v, u);
  mx1[u] = u;
  for (auto v : es[u])
    if (v != p && getlen(u, mx1[u]) < getlen(u, mx1[v])) mx1[u] = mx1[v];
}
void visit2(int u, int p) {
  int v1, v2;
  if (pmx[u] == 0) {
    v1 = u;
    v2 = 0;
  } else {
    v1 = pmx[u];
    v2 = u;
  }
  for (auto v : es[u])
    if (v != p) {
      if (getlen(u, v1) <= getlen(u, mx1[v])) {
        v2 = v1;
        v1 = mx1[v];
      } else if (getlen(u, v2) <= getlen(u, mx1[v])) {
        v2 = mx1[v];
      }
    }
  for (auto v : es[u])
    if (v != p) {
      pmx[v] = mx1[v] == v1 ? v2 : v1;
      visit2(v, u);
    }
}
void visit3(int u, int p) {
  for (auto v : es[u])
    if (v != p) visit3(v, u);
  int v1 = 0, v2 = 0, v3 = 0;
  for (auto v : es[u])
    if (v != p) {
      if (getlen(u, v1) <= getlen(u, mx1[v])) {
        v3 = v2;
        v2 = v1;
        v1 = mx1[v];
      } else if (getlen(u, v2) <= getlen(u, mx1[v])) {
        v3 = v2;
        v2 = mx1[v];
      } else if (getlen(u, v3) <= getlen(u, mx1[v]))
        v3 = mx1[v];
    }
  if (v1 != 0 && v2 != 0) mx2[u] = make_pair(1, make_pair(v1, v2));
  for (auto v : es[u])
    if (v != p && mx2[v] != zero &&
        comp(u, mx2[u], make_pair(mx2[v].first + 1, mx2[v].second)))
      mx2[u] = make_pair(mx2[v].first + 1, mx2[v].second);
  if (getlen(u, v1) <= getlen(u, pmx[u])) {
    v3 = v2;
    v2 = v1;
    v1 = pmx[u];
  } else if (getlen(u, v2) <= getlen(u, pmx[u])) {
    v3 = v2;
    v2 = pmx[u];
  } else if (getlen(u, v3) <= getlen(u, pmx[u])) {
    v3 = pmx[u];
  }
  for (auto v : es[u])
    if (v != p && mx2[v] != zero && mx2[v].first + 1 >= rshare) {
      int x1 = 0, x2 = 0;
      if (mx1[v] == v1) {
        x1 = v2;
        x2 = v3;
      } else if (mx1[v] == v2) {
        x1 = v1;
        x2 = v3;
      } else {
        x1 = v1;
        x2 = v2;
      }
      if (x1 == 0 || x2 == 0) continue;
      int l = getlen(u, mx2[v].second.first) + getlen(u, mx2[v].second.second) +
              getlen(u, x1) + getlen(u, x2);
      if (mx2[v].first + 1 > rshare || l > rlen) {
        rshare = mx2[v].first + 1;
        rlen = l;
        r1 = make_pair(x1, mx2[v].second.first);
        r2 = make_pair(x2, mx2[v].second.second);
      }
    }
  pair<int, pair<int, int> > p1 = zero, p2 = zero;
  for (auto v : es[u])
    if (v != p && mx2[v] != zero) {
      if (p1 == zero || comp(u, p1, mx2[v])) {
        p2 = p1;
        p1 = mx2[v];
      } else if (p2 == zero || comp(u, p2, mx2[v]))
        p2 = mx2[v];
    }
  if (p1 != zero && p2 != zero && p1.first + p2.first + 1 >= rshare) {
    int l = getlen(u, p1.second.first) + getlen(u, p1.second.second) +
            getlen(u, p2.second.first) + getlen(u, p2.second.second);
    if (p1.first + p2.first + 1 > rshare || l > rlen) {
      rshare = p1.first + p2.first + 1;
      rlen = l;
      r1 = make_pair(p1.second.first, p2.second.first);
      r2 = make_pair(p1.second.second, p2.second.second);
    }
  }
}
void process() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    es[u].push_back(v);
    es[v].push_back(u);
  }
  build_lca();
  check0();
  check1();
  visit1(1, 0);
  visit2(1, 0);
  visit3(1, 0);
  cout << r1.first << " " << r1.second << '\n';
  cout << r2.first << " " << r2.second << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  process();
}
