#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 200007;
vector<int> e[_];
int n, du[_] = {0}, able[_] = {0};
void dfs(int x, int ff) {
  if (du[x] >= 2) able[x] = 1;
  for (auto b : e[x]) {
    if (b == ff) continue;
    dfs(b, x);
    if (du[x] == 2 && !able[b]) able[x] = 0;
  }
}
struct cxk {
  int x, v;
  cxk(int x_ = 0, int v_ = 0) { x = x_, v = v_; }
  friend int operator<(cxk a, cxk b) { return a.v < b.v; }
} mx[_], cmx[_];
int f[_] = {0}, fs[_] = {0};
void dfs2(int x, int ff) {
  mx[x] = cxk(x, 0), cmx[x] = cxk(0, 0);
  fs[x] = x, f[fs[x]] = able[x];
  for (auto b : e[x]) {
    if (b == ff) continue;
    dfs2(b, x);
    cxk res = mx[b];
    res.v++;
    if (f[b] + able[x] > f[x])
      f[x] = f[b] + able[x], fs[x] = fs[b];
    else if (f[b] + able[x] == f[x] && able[b] &&
             mx[fs[x]].v + cmx[fs[x]].v <= mx[fs[b]].v + cmx[fs[b]].v)
      fs[x] = fs[b];
    if (mx[x] < res)
      cmx[x] = mx[x], mx[x] = res;
    else
      cmx[x] = max(cmx[x], res);
  }
}
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty();
  for (int i = 1, a, b; i < n; i++)
    a = ty(), b = ty(), e[a].emplace_back(b), e[b].emplace_back(a), du[a]++,
    du[b]++;
  int rt = 0;
  for (int i = 1; i <= n; i++)
    if (du[i] >= 3) rt = i;
  dfs(rt, 0), dfs2(rt, 0);
  int x = fs[rt], a = mx[x].x, b = cmx[x].x;
  dfs2(x, 0);
  int y = fs[x];
  cout << a << ' ' << mx[y].x << lf << b << ' ' << cmx[y].x << lf;
  return 0;
}
