#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;
struct star {
  int next, to;
};
int n, m, head[MAXN], len, dis[MAXN], num[MAXN];
int f[MAXN], s[MAXN], a1[MAXN], a2[MAXN];
star g[2 * MAXN];
queue<int> q;
bool can[MAXN];
void init() {
  memset(head, -1, sizeof(head));
  len = 0;
  memset(num, 0, sizeof(num));
  memset(can, true, sizeof(can));
}
void add(int u, int v) {
  g[++len].to = v;
  g[len].next = head[u];
  head[u] = len;
}
void queueClear() {
  while (!q.empty()) {
    q.pop();
  }
}
void pushup(int st) {
  queueClear();
  q.push(st);
  int ans = 0;
  int last = st;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    if (num[now] >= 3) {
      if (ans > f[now]) {
        s[now] = f[now];
        f[now] = ans;
        a2[now] = a1[now];
        a1[now] = st;
      } else if (ans > s[now]) {
        s[now] = ans;
        a2[now] = st;
      }
    } else {
      ++ans;
      for (int i = head[now]; i != -1; i = g[i].next) {
        if (g[i].to != last) {
          q.push(g[i].to);
          break;
        }
      }
      last = now;
    }
  }
}
int bfs(int st) {
  queueClear();
  q.push(st);
  memset(dis, -1, sizeof(dis));
  dis[st] = 0;
  int re = 0;
  int maxDis = -1, maxn = -1;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    if (dis[now] > maxDis && num[now] >= 3) {
      maxDis = dis[now];
      re = now;
      maxn = f[now] + s[now];
    } else if (dis[now] == maxDis && num[now] >= 3) {
      if (f[now] + s[now] > maxn) {
        maxn = f[now] + s[now];
        re = now;
      }
    }
    for (int i = head[now]; i != -1; i = g[i].next) {
      if (dis[g[i].to] == -1) {
        dis[g[i].to] = dis[now] + 1;
        q.push(g[i].to);
      }
    }
  }
  return re;
}
int main() {
  scanf("%d", &n);
  init();
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
    ++num[u];
    ++num[v];
  }
  memset(f, 0, sizeof(f));
  memset(s, 0, sizeof(s));
  for (int i = 1; i <= n; ++i) {
    if (num[i] == 1) {
      pushup(i);
    }
  }
  int p1 = bfs(1);
  int p2 = bfs(p1);
  printf("%d %d\n%d %d\n", a1[p1], a1[p2], a2[p1], a2[p2]);
  return 0;
}
