#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
vector<int> e[N];
pair<int, int> mx[N], mx2[N], ans;
int dep[N], n, p;
void dfs(int x, int fa) {
  mx[x] = pair<int, int>(-1, x);
  mx2[x] = pair<int, int>(-1, 0);
  for (auto i : e[x])
    if (i != fa) {
      dep[i] = dep[x] + 1;
      dfs(i, x);
      if (mx[i].first > mx[x].first)
        mx2[x] = mx[x], mx[x] = mx[i];
      else if (mx[i].first > mx2[x].first)
        mx2[x] = mx[i];
    }
  mx[x].first++;
  mx2[x].first++;
  if ((e[x].size() - (fa != 0)) >= 2) {
    pair<int, int> tmp(dep[x], mx[x].first + mx2[x].first);
    if (tmp > ans) ans = tmp, p = x;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  int x1, x2, x3, x4;
  dfs(1, 0);
  x1 = mx[p].second, x2 = mx2[p].second;
  ans = pair<int, int>(0, 0);
  dep[p] = 0;
  dfs(p, 0);
  printf("%d %d\n%d %d\n", x1, mx[p].second, x2, mx2[p].second);
}
