#include <bits/stdc++.h>
int n, head[233333], cnt = 0, dep[233333], mx, ay, by, len, pnt[233333];
struct edge {
  int to, nxt;
} e[233333 << 1];
void dfs(int now) {
  int mine = 0;
  int nmx = 0;
  for (int i = head[now]; i; i = e[i].nxt)
    if (!dep[e[i].to]) {
      ++mine;
      dep[e[i].to] = dep[now] + 1;
      dfs(e[i].to);
      if (dep[pnt[e[i].to]] > dep[pnt[now]]) {
        nmx = pnt[now], pnt[now] = pnt[e[i].to];
      } else {
        if (dep[pnt[e[i].to]] > dep[nmx]) {
          nmx = pnt[e[i].to];
        }
      }
    }
  if (mine == 0) {
    pnt[now] = now;
  }
  if (mine > 1 && (dep[now] > dep[mx] ||
                   dep[now] == dep[mx] && dep[pnt[now]] + dep[nmx] > len)) {
    mx = now;
    len = dep[pnt[now]] + dep[nmx];
  }
}
void addEdge(int u, int v) {
  e[++cnt] = (edge){v, head[u]};
  head[u] = cnt;
  e[++cnt] = (edge){u, head[v]};
  head[v] = cnt;
}
void dfs_ans(int now) {
  int mine = 0;
  for (int i = head[now]; i; i = e[i].nxt)
    if (dep[e[i].to] > dep[now]) {
      ++mine;
      dfs_ans(e[i].to);
    }
  if (!mine) {
    if (dep[ay] < dep[now]) {
      by = ay;
      ay = now;
    } else if (dep[by] < dep[now])
      by = now;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    addEdge(u, v);
  }
  dep[1] = 1;
  dfs(1);
  int dx = mx;
  ay = by = 0;
  dfs_ans(dx);
  int ax = ay, bx = by;
  memset(dep, 0, sizeof dep);
  dep[dx] = 1;
  mx = len = 0;
  dfs(dx);
  dx = mx;
  ay = by = 0;
  dfs_ans(dx);
  printf("%d %d\n%d %d\n", ax, ay, bx, by);
  return 0;
}
