#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200010];
int lr[200010], nc[200010], comm[200010];
pair<int, int> subt[200010];
pair<pair<int, int>, pair<int, int> > answers[200010];
int vis[200010], par[200010];
int have[200010], farth[200010], dep[200010], len[200010];
int comp(pair<int, pair<int, int> > p1, pair<int, pair<int, int> > p2) {
  if (p1.first != p2.first) return p1.first > p2.first;
  return p1.second.first > p2.second.first;
}
void solve(int i) {
  if (vis[i]) return;
  vis[i] = 1;
  int c = 0;
  for (auto j : adj[i]) {
    if (!vis[j]) par[j] = i, c++;
    solve(j);
  }
  if (c == 0) {
    dep[i] = 1;
    len[i] = 0;
    farth[i] = i;
    return;
  }
  if (c == 1) {
    for (auto j : adj[i])
      if (par[j] == i)
        comm[i] = 1 + comm[j], farth[i] = farth[j], lr[i] = lr[j],
        len[i] = 2 + len[j], dep[i] = 1 + dep[j], have[i] = have[j],
        nc[i] = nc[j], answers[i] = answers[j], subt[i] = subt[j];
    return;
  }
  have[i] = 1;
  int mx = 0;
  for (auto j : adj[i])
    if (par[j] == i)
      if (dep[j] >= mx) mx = dep[j], farth[i] = farth[j];
  dep[i] = 1 + mx;
  vector<pair<int, pair<int, int> > > v4;
  for (auto j : adj[i])
    if (par[j] == i) v4.push_back({dep[j], {farth[j], j}});
  sort(v4.begin(), v4.end());
  reverse(v4.begin(), v4.end());
  if (v4.size() >= 4)
    nc[i] = 1, lr[i] = v4[0].first + v4[1].first + v4[2].first + v4[3].first,
    answers[i] = {{v4[0].second.first, v4[1].second.first},
                  {v4[2].second.first, v4[3].second.first}};
  if (v4.size() >= 2)
    comm[i] = 1, len[i] = v4[0].first + v4[1].first,
    subt[i] = {v4[0].second.first, v4[1].second.first};
  for (auto j : adj[i]) {
    if (par[j] == i) {
      if (have[j] && len[j] + 2 > len[i]) len[i] = len[j], subt[i] = subt[j];
    }
  }
  vector<pair<int, pair<int, int> > > v3;
  for (auto j : adj[i])
    if (par[j] == i && have[j]) v3.push_back({comm[j], {len[j], j}});
  sort(v3.begin(), v3.end(), comp);
  if (!v3.empty()) {
    len[i] = 2 + v3[0].second.first;
    subt[i] = subt[v3[0].second.second];
    comm[i] = 1 + comm[v3[0].second.second];
  }
  if (!v3.empty() && v3.size() == 1) {
    int newlen = 0, fr = -1, se = -1;
    for (int j = 0; j < v4.size(); j++)
      if (have[v4[j].second.second])
        continue;
      else if (fr == -1)
        fr = v4[j].second.first, newlen += v4[j].first;
      else if (se == -1)
        se = v4[j].second.first, newlen += v4[j].first;
      else
        break;
    if (fr != -1 && se != -1 && v3[0].first >= 1)
      nc[i] = 1 + v3[0].first, lr[i] = newlen + 2 + v3[0].second.first,
      answers[i] = {subt[v3[0].second.second], {fr, se}};
  } else if (!v3.empty() && v3.size() >= 2) {
    nc[i] = 1 + v3[0].first + v3[1].first;
    lr[i] = 4 + v3[0].second.first + v3[1].second.first;
    answers[i] = {subt[v3[0].second.second], subt[v3[1].second.second]};
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  bool b = false;
  for (int i = 0; i < n; i++) par[i] = -1;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<int> poss;
  for (int i = 0; i < n; i++) {
    if (adj[i].size() >= 3) {
      solve(i);
      break;
    }
  }
  int mx1 = 0, mx2 = 0;
  for (int i = 0; i < n; i++) {
    if (!have[i]) continue;
    if (nc[i] > mx1 || (nc[i] == mx1 && lr[i] > mx2)) {
      mx1 = nc[i], mx2 = lr[i];
    }
  }
  for (int i = 0; i < n; i++)
    if (have[i] && nc[i] == mx1 && lr[i] == mx2) {
      cout << answers[i].first.first + 1 << ' ' << answers[i].second.first + 1
           << "\n"
           << answers[i].first.second + 1 << ' ' << answers[i].second.second + 1
           << endl;
      return 0;
    }
}
