#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9 + 7;
const long long INFF = (long long)2e18;
const int mod = (int)1e9 + 7;
const int MXN = (int)2e5 + 7;
int dep[MXN];
struct node {
  int v, f1, f2, l;
  node(){};
  node(int _v, int _f1, int _f2) {
    v = _v, f1 = _f1, f2 = _f2;
    l = dep[f1] + dep[f2] - 2 * dep[v];
  }
  const bool operator<(const node &p2) const {
    if (dep[v] != dep[p2.v]) return dep[v] < dep[p2.v];
    return l < p2.l;
  }
};
vector<int> edge[MXN];
int bst[MXN][2];
int in[MXN], out[MXN], cntp;
void dfs(int u, int pa, int dpt) {
  dep[u] = dpt;
  bst[u][0] = bst[u][1] = u;
  in[u] = ++cntp;
  for (int v : edge[u]) {
    if (v == pa) continue;
    dfs(v, u, dpt + 1);
    if (dep[bst[v][0]] > dep[bst[u][0]]) {
      bst[u][1] = bst[u][0];
      bst[u][0] = bst[v][0];
    } else if (dep[bst[v][0]] > dep[bst[u][1]]) {
      bst[u][1] = bst[v][0];
    }
  }
  out[u] = cntp;
}
int d1, d2;
int s1, e1, s2, e2;
node dp[MXN];
int ck(int u, int v) {
  if (in[v] <= in[u] && out[u] <= out[v]) return true;
  return false;
}
void dfs2(int u, int pa, int dis, int fr) {
  for (int v : edge[u]) {
    if (v == pa) continue;
    if (in[v] <= in[bst[u][0]] && out[bst[u][0]] <= out[v]) {
      if (dis > dep[bst[u][1]] - dep[u])
        dfs2(v, u, dis + 1, fr);
      else
        dfs2(v, u, dep[bst[u][1]] - dep[u] + 1, bst[u][1]);
    } else {
      if (dis > dep[bst[u][0]] - dep[u])
        dfs2(v, u, dis + 1, fr);
      else
        dfs2(v, u, dep[bst[u][0]] - dep[u] + 1, bst[u][0]);
    }
    if (dp[v].v == 0) continue;
    if (dis && bst[u][0] != u && !ck(bst[u][0], v)) {
      int v1 = dep[dp[v].v] - dep[u];
      int v2 = dis + dep[bst[u][0]] - dep[u] + dp[v].l;
      if (d1 < v1 || (d1 == v1 && d2 < v2)) {
        d1 = v1, d2 = v2;
        s1 = fr, e1 = bst[u][0];
        s2 = dp[v].f1, e2 = dp[v].f2;
      }
    }
    if (dis && bst[u][1] != u && !ck(bst[u][1], v)) {
      int v1 = dep[dp[v].v] - dep[u];
      int v2 = dis + dep[bst[u][1]] - dep[u] + dp[v].l;
      if (d1 < v1 || (d1 == v1 && d2 < v2)) {
        d1 = v1, d2 = v2;
        s1 = fr, e1 = bst[u][1];
        s2 = dp[v].f1, e2 = dp[v].f2;
      }
    }
    if (dp[u].v) {
      int v1 = dep[dp[u].v] + dep[dp[v].v] - 2 * dep[u];
      int v2 = dp[u].l + dp[v].l;
      if (d1 < v1 || (d1 == v1 && d2 < v2)) {
        d1 = v1, d2 = v2;
        s1 = dp[u].f1, e1 = dp[u].f2;
        s2 = dp[v].f1, e2 = dp[v].f2;
      }
    }
    if (dp[u] < dp[v]) {
      dp[u] = dp[v];
    }
  }
  if (dp[u].v == 0 && bst[u][0] != u && bst[u][1] != u) {
    dp[u] = node(u, bst[u][0], bst[u][1]);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  int rt = 0;
  for (int i = 1; i <= n; i++)
    if ((int)(edge[i]).size() == 1) rt = i;
  dfs(rt, 0, 1);
  dfs2(rt, 0, 0, rt);
  printf("%d %d\n%d %d\n", s1, e2, s2, e1);
  return 0;
}
