#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, z, k, w, a, b, res, dist;
vector<int> edge[200005], new_edge[200005];
int deg[200005], depth[200005], far[200005], far_dist[200005];
pair<int, int> dp[200005];
bool has_crit_point[200005];
void DFS(int x, int y, int pre) {
  if (y == 0)
    depth[x] = 0;
  else
    depth[x] = depth[y] + 1;
  int nxt_pre = pre;
  if (deg[x] >= 3) {
    has_crit_point[x] = 1;
    nxt_pre = x;
    if (pre != 0) {
      new_edge[pre].push_back(x);
      new_edge[x].push_back(pre);
    }
  }
  for (int i : edge[x])
    if (i != y) DFS(i, x, nxt_pre), has_crit_point[x] |= has_crit_point[i];
  if (!has_crit_point[x]) dp[x].first = x;
  for (int i : edge[x])
    if (!has_crit_point[i]) {
      if (dp[x].first == 0 || depth[dp[i].first] >= depth[dp[x].first])
        dp[x].second = dp[x].first, dp[x].first = dp[i].first;
      else if (dp[x].second == 0 || depth[dp[i].first] > depth[dp[x].second])
        dp[x].second = dp[i].first;
    }
}
void solve(int x, int y) {
  for (int i : new_edge[x])
    if (i != y) solve(i, x);
  int p = -1, q = -1, distp = 0, distq = 0;
  if (dp[x].second > 0) {
    far[x] = x;
    far_dist[x] = depth[dp[x].first] + depth[dp[x].second] - 2 * depth[x];
  }
  for (int i : new_edge[x]) {
    int v = i;
    int distv =
        depth[dp[far[v]].first] + depth[dp[far[v]].second] - depth[far[v]] * 2;
    if (p == -1 || depth[far[v]] > depth[p])
      q = p, distq = distp, p = far[v], distp = distv;
    else if (depth[far[v]] == depth[p] && distv > distp)
      q = p, distq = distp, p = far[v], distp = distv;
    else if (q == -1 || depth[far[v]] > depth[q])
      distq = distv, q = far[v];
    else if (depth[far[v]] == depth[q] && distv > distq)
      distq = distv, q = far[v];
    if (depth[far[v]] > depth[far[x]])
      far[x] = far[v], far_dist[x] = far_dist[v];
    else if (depth[far[v]] == depth[far[x]] && far_dist[v] > far_dist[x])
      far[x] = far[v], far_dist[x] = far_dist[v];
  }
  if (dp[x].second > 0 && q == -1)
    q = x, distq = depth[dp[x].first] + depth[dp[x].second] - 2 * depth[x];
  if (p == -1 || q == -1) return;
  if (depth[p] + depth[q] - 2 * depth[x] > res) {
    res = depth[p] + depth[q] - 2 * depth[x];
    dist = distp + distq;
    a = p, b = q;
  } else if (depth[p] + depth[q] - 2 * depth[x] == res &&
             distp + distq > dist) {
    dist = distp + distq;
    a = p, b = q;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n - 1); i++)
    scanf("%d %d", &x, &y), edge[x].push_back(y), edge[y].push_back(x),
        deg[x]++, deg[y]++;
  for (int i = (1); i <= (n); i++)
    if (deg[i] >= 3) x = i;
  DFS(x, 0, 0);
  a = b = -1;
  res = dist = 0;
  solve(x, 0);
  printf("%d %d\n%d %d\n", dp[a].first, dp[b].first, dp[a].second,
         dp[b].second);
  return 0;
}
