#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, mx[N], mx2[N], dep[N], p, ans1, ans2, ans3, ans4;
vector<int> G[N];
pair<int, int> max1;
void dfs(int u, int fa) {
  mx[u] = mx2[u] = 0;
  int son = 0;
  for (int i = 0; i < G[u].size(); i++)
    if (G[u][i] != fa) {
      dep[G[u][i]] = dep[u] + 1;
      dfs(G[u][i], u);
      if (!mx[u] || dep[mx[G[u][i]]] > dep[mx[u]])
        mx2[u] = mx[u], mx[u] = mx[G[u][i]];
      else if (!mx2[u] || dep[mx[G[u][i]]] > dep[mx2[u]])
        mx2[u] = mx[G[u][i]];
      son++;
    }
  if (!son) mx[u] = u;
  if (son >= 2)
    if (pair<int, int>(dep[u], dep[mx[u]] + dep[mx2[u]]) > max1)
      max1 = pair<int, int>(dep[u], dep[mx[u]] + dep[mx2[u]]), p = u;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; i++)
    scanf("%d%d", &x, &y), G[x].push_back(y), G[y].push_back(x);
  max1 = pair<int, int>(0, 0);
  dfs(1, 0);
  ans1 = mx[p], ans2 = mx2[p];
  max1 = pair<int, int>(0, 0);
  dep[p] = 0;
  dfs(p, 0);
  ans3 = mx[p], ans4 = mx2[p];
  printf("%d %d\n%d %d\n", ans1, ans3, ans2, ans4);
}
