#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
bool vis[200100];
int sp[200100], leavesCnt[200100], par[200100];
vector<int> G[200100];
int dfs(int src) {
  vis[src] = true;
  for (int i = 0; i < G[src].size(); i++) {
    if (!vis[G[src][i]]) leavesCnt[src] += dfs(G[src][i]), par[G[src][i]] = src;
  }
  if (G[src].size() == 1) return 1;
  return leavesCnt[src];
}
vector<int> bfs(int src) {
  queue<int> q;
  q.push(src);
  sp[src] = 0;
  vector<int> ret;
  int maxLen = -1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (leavesCnt[u] > 1) {
      if (sp[u] > maxLen) ret.clear();
      ret.push_back(u);
      maxLen = sp[u];
    }
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (sp[v] == -1) q.push(v), sp[v] = sp[u] + 1;
    }
  }
  return ret;
}
vector<int> getFurthestLeaves(int src, int cnt) {
  queue<int> q;
  q.push(src);
  sp[src] = 0;
  vector<int> ret;
  stack<int> st;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (G[u].size() == 1) {
      st.push(u);
    }
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (sp[v] == -1) q.push(v), sp[v] = sp[u] + 1;
    }
  }
  while (!st.empty() && cnt--) ret.push_back(st.top()), st.pop();
  return ret;
}
int getBestNode(int root) {
  memset(vis, 0, sizeof(vis));
  memset(leavesCnt, 0, sizeof(leavesCnt));
  memset(sp, -1, sizeof(sp));
  dfs(root);
  vector<int> candidates = bfs(root);
  memset(sp, -1, sizeof(sp));
  int bestSum = 0;
  int ret = 0;
  for (int i = 0; i < candidates.size(); i++) {
    sp[par[candidates[i]]] = 1;
    vector<int> v = getFurthestLeaves(candidates[i], 2);
    if (sp[v[0]] + sp[v[1]] > bestSum) {
      bestSum = sp[v[0]] + sp[v[1]];
      ret = candidates[i];
    }
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int a = getBestNode(1);
  int aParent = par[a];
  int b = getBestNode(a);
  int bParent = par[b];
  if (a == b) {
    memset(sp, -1, sizeof(sp));
    vector<int> ans = getFurthestLeaves(a, 4);
    cout << ans[0] << ' ' << ans[1] << endl << ans[2] << ' ' << ans[3] << endl;
    return 0;
  }
  memset(sp, -1, sizeof(sp));
  sp[aParent] = 1;
  vector<int> ans1 = getFurthestLeaves(a, 2);
  memset(sp, -1, sizeof(sp));
  sp[bParent] = 1;
  vector<int> ans2 = getFurthestLeaves(b, 2);
  cout << ans1[0] << ' ' << ans2[0] << endl;
  cout << ans1[1] << ' ' << ans2[1] << endl;
  return 0;
}
