#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  x = f ? -x : x;
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
template <class T>
inline bool chkmax(T &a, T const &b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
inline bool chkmin(T &a, T const &b) {
  return a > b ? a = b, 1 : 0;
}
const int N = 2e5 + 10;
int n, mx1[N], mx2[N], head[N], dep[N], root, ecnt;
pair<int, int> res;
struct edge {
  int to, nxt;
} e[N * 2];
void addedge(int u, int v) {
  e[++ecnt] = (edge){v, head[u]};
  head[u] = ecnt;
  e[++ecnt] = (edge){u, head[v]};
  head[v] = ecnt;
}
void dfs(int u, int fa) {
  mx1[u] = mx2[u] = 0;
  int son = 0;
  for (int i = head[u], v; i; i = e[i].nxt)
    if ((v = e[i].to) != fa) {
      ++son;
      dep[v] = dep[u] + 1;
      dfs(v, u);
      if (dep[mx1[u]] <= dep[mx1[v]])
        mx2[u] = mx1[u], mx1[u] = mx1[v];
      else if (dep[mx2[u]] < dep[mx1[v]])
        mx2[u] = mx1[v];
    }
  if (!son)
    mx1[u] = u;
  else if (son >= 2) {
    pair<int, int> tmp =
        make_pair(dep[u], dep[mx1[u]] + dep[mx2[u]] - 2 * dep[u]);
    if (chkmax(res, tmp)) root = u;
  }
}
int main() {
  read(n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    read(u), read(v);
    addedge(u, v);
  }
  res = make_pair(0, 0);
  dfs(1, 0);
  int ans1 = mx1[root], ans3 = mx2[root];
  dep[root] = 0;
  res = make_pair(0, 0);
  dfs(root, 0);
  int ans2 = mx1[root], ans4 = mx2[root];
  printf("%d %d\n%d %d\n", ans1, ans2, ans3, ans4);
}
