#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
vector<int> adj[N];
bool vis[N];
pair<int, int> len[N], vtx[N];
pair<pair<int, int>, pair<int, int> > ans;
pair<int, int> opt;
bool compare(int i, int j) { return len[i] > len[j]; }
void solve(int v) {
  vis[v] = true;
  vector<int> pth, tre;
  for (auto u : adj[v]) {
    if (!vis[u]) {
      solve(u);
      if (len[u].first < 1)
        pth.push_back(u);
      else
        tre.push_back(u);
    }
  }
  sort(tre.begin(), tre.end(), compare);
  sort(pth.begin(), pth.end(), compare);
  if (tre.size() == 0) {
    if (pth.size() == 0) {
      len[v] = make_pair(0, 1);
      vtx[v] = make_pair(v, 0);
    } else if (pth.size() == 1) {
      len[v] = make_pair(0, len[pth[0]].second + 1);
      vtx[v] = vtx[pth[0]];
    } else if (pth.size() >= 2) {
      len[v] = make_pair(1, len[pth[0]].second + len[pth[1]].second);
      vtx[v] = make_pair(vtx[pth[0]].first, vtx[pth[1]].first);
    }
    return;
  }
  len[v] = make_pair(len[tre[0]].first + 1, len[tre[0]].second);
  vtx[v] = vtx[tre[0]];
  if (tre.size() == 1 and pth.size() >= 2) {
    pair<int, int> tl = len[tre[0]], pl1 = len[pth[0]], pl2 = len[pth[1]];
    pair<int, int> val =
        make_pair(tl.first + 1, tl.second + pl1.second + pl2.second);
    if (val > opt) {
      pair<int, int> tv = vtx[tre[0]], pv1 = vtx[pth[0]], pv2 = vtx[pth[1]];
      ans = make_pair(make_pair(tv.first, pv1.first),
                      make_pair(tv.second, pv2.first));
      opt = val;
    }
  }
  if (tre.size() >= 2) {
    pair<int, int> tl1 = len[tre[0]], tl2 = len[tre[1]];
    pair<int, int> val =
        make_pair(tl1.first + tl2.first + 1, tl1.second + tl2.second);
    if (val > opt) {
      pair<int, int> tv1 = vtx[tre[0]], tv2 = vtx[tre[1]];
      ans = make_pair(make_pair(tv1.first, tv2.first),
                      make_pair(tv1.second, tv2.second));
      opt = val;
    }
  }
  return;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int r;
  for (int i = 1; i <= n; i++) {
    if (adj[i].size() > 2) {
      r = i;
      break;
    }
  }
  memset(vis, false, sizeof vis);
  solve(r);
  cout << ans.first.first << " " << ans.first.second << endl;
  cout << ans.second.first << " " << ans.second.second << endl;
  return 0;
}
