#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
vector<int> graph[MAXN];
int n;
int mx1[MAXN], mx2[MAXN], layer[MAXN];
int maxv;
void dfs(int u, int pre = -1) {
  int sz = graph[u].size();
  mx1[u] = u;
  for (int i = 0; i < sz; i++) {
    int v = graph[u][i];
    if (v == pre) {
      continue;
    }
    layer[v] = layer[u] + 1;
    dfs(v, u);
    if (layer[mx1[v]] > layer[mx1[u]]) {
      mx2[u] = mx1[u];
      mx1[u] = mx1[v];
    } else if (layer[mx1[v]] > layer[mx2[u]]) {
      mx2[u] = mx1[v];
    }
  }
  if (sz >= 3) {
    if (layer[u] == layer[maxv]) {
      if (layer[mx1[u]] + layer[mx2[u]] > layer[mx1[maxv]] + layer[mx2[maxv]]) {
        maxv = u;
      }
    } else if (layer[u] > layer[maxv]) {
      maxv = u;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(1);
  int a1, b1, a2, b2;
  a1 = mx1[maxv];
  a2 = mx2[maxv];
  memset(mx1, 0, sizeof(mx1));
  memset(mx2, 0, sizeof(mx2));
  layer[maxv] = 0;
  dfs(maxv);
  b1 = mx1[maxv];
  b2 = mx2[maxv];
  printf("%d %d\n%d %d\n", a1, b1, a2, b2);
  return 0;
}
