#include <bits/stdc++.h>
const int N = 2e5 + 5;
using namespace std;
vector<int> G[N], mv[2];
int n, root, root2, Max, d[N];
int ret1, ret2, ret3, ret4;
pair<int, int> ret[N];
void dfs(int u, int p) {
  for (auto v : G[u]) {
    if (v == p) continue;
    d[v] = d[u] + 1;
    dfs(v, u);
    if (!ret[u].first || d[ret[u].first] < d[ret[v].first])
      ret[u].second = ret[u].first, ret[u].first = ret[v].first;
    else if (!ret[u].second || d[ret[u].second] < d[ret[v].first])
      ret[u].second = ret[v].first;
  }
  if (G[u].size() == 1) ret[u].first = u;
  if (G[u].size() >= 3) {
    if (d[root] < d[u] ||
        (d[u] == d[root] && d[ret[root].first] + d[ret[root].second] <
                                d[ret[u].first] + d[ret[u].second]))
      root = u;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
    if (G[u].size() >= 3) root = u;
    if (G[v].size() >= 3) root = v;
  }
  dfs(root, root);
  ret1 = ret[root].first;
  ret2 = ret[root].second;
  for (int i = 1; i <= n; i++) ret[i] = pair<int, int>(0, 0), d[i] = 0;
  dfs(root, root);
  ret3 = ret[root].first;
  ret4 = ret[root].second;
  cout << ret1 << " " << ret3 << "\n";
  cout << ret2 << " " << ret4 << "\n";
}
