#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 4, oo = 1e9 + 7;
long long n;
vector<long long> adj[N];
bool Disable[N];
long long numChild[N], total;
void DFS_CountChild(long long par, long long u) {
  numChild[u] = 1;
  for (long long v : adj[u])
    if (v != par && !Disable[v]) {
      DFS_CountChild(u, v);
      numChild[u] += numChild[v];
    }
}
long long Find_centroid(long long par, long long u) {
  for (long long v : adj[u])
    if (v != par && !Disable[v])
      if (numChild[v] > total / 2) return Find_centroid(u, v);
  return u;
}
pair<long long, long long> dp[N], Trace[N];
long long hei[N], Home[N];
void DFS_Reset(long long par, long long u) {
  dp[u] = pair<long long, long long>(-oo, -oo);
  Trace[u] = pair<long long, long long>(-oo, -oo);
  hei[u] = Home[u] = 0;
  for (long long v : adj[u])
    if (v != par && !Disable[v]) DFS_Reset(u, v);
}
void DFS_getDp(long long par, long long u) {
  long long counter = 0, L = -oo, R = -oo;
  pair<long long, long long> best = pair<long long, long long>(-oo, -oo);
  Home[u] = u;
  for (long long v : adj[u])
    if (v != par && !Disable[v]) {
      DFS_getDp(u, v);
      ++counter;
      if (hei[u] < hei[v] + 1) {
        hei[u] = hei[v] + 1;
        Home[u] = Home[v];
      }
      if (best.first < hei[v]) {
        best.second = best.first;
        best.first = hei[v];
        L = R;
        R = Home[v];
      } else if (best.second < hei[v]) {
        best.second = hei[v];
        L = Home[v];
      }
    }
  if (counter >= 2) {
    dp[u] = pair<long long, long long>(1, best.first + best.second + 2);
    Trace[u] = pair<long long, long long>(L, R);
  }
  for (long long v : adj[u])
    if (v != par && !Disable[v]) {
      if (dp[u].first < dp[v].first + 1) {
        dp[u].first = dp[v].first + 1;
        dp[u].second = dp[v].second + 2;
        Trace[u] = Trace[v];
      } else if (dp[u].first == dp[v].first + 1 &&
                 dp[u].second < dp[v].second + 2) {
        dp[u].second = dp[v].second + 2;
        Trace[u] = Trace[v];
      }
    }
}
pair<long long, long long> res = pair<long long, long long>(-oo, -oo), Pos1,
                           Pos2;
void process(long long par, long long u) {
  DFS_Reset(par, u);
  DFS_getDp(par, u);
  pair<long long, long long> best0 = pair<long long, long long>(-oo, -oo),
                             best1 = pair<long long, long long>(-oo, -oo);
  long long L = -oo, R = -oo;
  for (long long v : adj[u])
    if (v != par && !Disable[v]) {
      if (best0 < dp[v]) {
        best1 = best0;
        best0 = pair<long long, long long>(dp[v].first, dp[v].second);
        L = R;
        R = v;
      } else if (best1 < dp[v])
        best1 = dp[v], L = v;
    }
  pair<long long, long long> val = pair<long long, long long>(
      best0.first + best1.first + 1, best0.second + best1.second + 4);
  if (res < val && val.first >= 0) {
    res = val;
    Pos1 = Trace[L];
    Pos2 = Trace[R];
  }
  if (best0.first >= 0 && best1.first < 0) {
    pair<long long, long long> alone = pair<long long, long long>(-oo, -oo),
                               ver = pair<long long, long long>(-oo, -oo);
    for (long long v : adj[u])
      if (v != par && !Disable[v]) {
        if (dp[v] == best0) continue;
        if (alone.first < hei[v]) {
          alone.second = alone.first;
          alone.first = hei[v];
          ver.second = ver.first;
          ver.first = v;
        } else if (alone.second < hei[v]) {
          alone.second = hei[v];
          ver.second = v;
        }
      }
    pair<long long, long long> val = pair<long long, long long>(
        best0.first + 1, alone.first + alone.second + best0.second + 4);
    if (res < val && val.first >= 0) {
      res = val;
      Pos1 = Trace[R];
      Pos2 = pair<long long, long long>(Home[ver.first], Home[ver.second]);
    }
  }
}
void Centroid_Decompose(long long par, long long u) {
  DFS_CountChild(par, u);
  total = numChild[u];
  long long centroid = Find_centroid(par, u);
  process(par, centroid);
  Disable[centroid] = true;
  for (long long v : adj[centroid])
    if (v != par && !Disable[v]) Centroid_Decompose(centroid, v);
}
void sol() {
  Centroid_Decompose(0, 1);
  cout << Pos1.first << " " << Pos2.first << '\n';
  cout << Pos1.second << " " << Pos2.second << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
  }
  cin >> n;
  long long u, v;
  for (long long i = 1; i < n; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  sol();
  return 0;
}
