#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
vector<int> g[MAXN];
pair<int, int> mx;
int pos, dep[MAXN], fir[MAXN], sec[MAXN];
void dfs(int u, int pre, int d) {
  dep[u] = d;
  int son = 0;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == pre) continue;
    ++son;
    dfs(v, u, d + 1);
    if (dep[fir[v]] > dep[fir[u]])
      sec[u] = fir[u], fir[u] = fir[v];
    else if (dep[fir[v]] > dep[sec[u]])
      sec[u] = fir[v];
  }
  if (son == 0) fir[u] = u;
  if (son >= 2) {
    pair<int, int> tmp = pair<int, int>(dep[u], dep[fir[u]] + dep[sec[u]]);
    if (tmp > mx) mx = tmp, pos = u;
  }
}
int main() {
  int n, u, v;
  scanf("%d", &n);
  memset(fir, 0, sizeof(fir));
  memset(sec, 0, sizeof(sec));
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  mx = pair<int, int>(0, 0), pos = 0;
  dfs(1, 0, 0);
  int a1 = fir[pos], a2 = sec[pos];
  memset(fir, 0, sizeof(fir));
  memset(sec, 0, sizeof(sec));
  mx = pair<int, int>(0, 0);
  dfs(pos, 0, 0);
  int a3 = fir[pos], a4 = sec[pos];
  printf("%d %d\n%d %d", a1, a3, a2, a4);
  return 0;
}
