#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int)1e9 + 23111992;
const long long LINF = (long long)1e18 + 23111992;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline unsigned long long isqrt(unsigned long long k) {
  unsigned long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int myrand() { return abs((int)mt()); }
const int maxn = 2e5 + 5;
const int logn = 20;
int n;
vector<int> adj[maxn];
int lev[maxn];
int par[logn][maxn];
int used[maxn];
void dfs(int u, int p) {
  for (int i = (1); i < (logn); ++i) par[i][u] = par[i - 1][par[i - 1][u]];
  for (int v : adj[u]) {
    if (v != p) {
      lev[v] = lev[u] + 1;
      par[0][v] = u;
      dfs(v, u);
    }
  }
}
int lca(int u, int v) {
  if (lev[u] < lev[v]) swap(u, v);
  for (int i = (logn)-1; i >= (0); --i) {
    if (lev[par[i][u]] >= lev[v]) {
      u = par[i][u];
    }
  }
  if (u == v) return u;
  for (int i = (logn)-1; i >= (0); --i) {
    if (par[i][u] != par[i][v]) {
      u = par[i][u];
      v = par[i][v];
    }
  }
  return par[0][u];
}
pair<int, int> best;
int from[maxn];
void dfs(int u, int p, int lev) {
  chkmax(best, make_pair(lev, u));
  for (int v : adj[u]) {
    if (v != p && used[v]) {
      from[v] = u;
      dfs(v, u, lev + 1);
    }
  }
}
int center(int rt) {
  best = make_pair(0, 0);
  dfs(rt, -1, 0);
  int st = best.second;
  best = make_pair(0, 0);
  dfs(st, -1, 0);
  int ed = best.second;
  int len = best.first;
  for (int i = (0); i < (len >> 1); ++i) ed = from[ed];
  return ed;
}
int isleaf[maxn];
int ff[maxn];
void dfs2(int u, int p, int seanc = -1) {
  ff[u] = seanc;
  int num = 0;
  for (int v : adj[u]) {
    if (used[v]) {
      num++;
    }
    if (v != p && used[v]) {
      lev[v] = lev[u] + 1;
      int nseanc = seanc;
      if (nseanc == -1) nseanc = v;
      dfs2(v, u, nseanc);
    }
  }
  if (num == 1) {
    isleaf[u] = 1;
  }
}
pair<int, int> f[maxn];
pair<int, int> g[maxn];
void dfs3(int u, int p) {
  vector<pair<int, int> > vals;
  vals.push_back(make_pair(0, u));
  for (int v : adj[u]) {
    if (v != p && !used[v]) {
      dfs3(v, u);
      vals.push_back(make_pair(f[v].first + 1, f[v].second));
    }
  }
  sort((vals).begin(), (vals).end(), greater<pair<int, int> >());
  f[u] = vals[0];
  if (int((vals).size()) > 1) {
    g[u] = vals[1];
  } else {
    g[u] = make_pair(-INF, -INF);
  }
}
void chemthan() {
  cin >> n;
  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);
  }
  dfs(0, -1);
  vector<int> ver;
  for (int u = (0); u < (n); ++u)
    if (int((adj[u]).size()) >= 3) ver.push_back(u);
  int rt = ver[0];
  for (int u : ver) rt = lca(rt, u);
  used[rt] = 1;
  for (int i = (0); i < (int((ver).size())); ++i) {
    int u = ver[i];
    while (u != rt && !used[u]) {
      used[u] = 1;
      u = par[0][u];
    }
  }
  rt = center(rt);
  dfs2(rt, -1);
  map<int, pair<pair<int, int>, pair<int, int> > > hs;
  vector<pair<pair<int, int>, pair<int, int> > > vals;
  for (int u = (0); u < (n); ++u)
    if (isleaf[u]) {
      dfs3(u, -1);
      chkmax(hs[ff[u]], make_pair(make_pair(lev[u], f[u].first + g[u].first),
                                  make_pair(f[u].second, g[u].second)));
    }
  for (auto it : hs) {
    vals.push_back(it.second);
  }
  sort((vals).begin(), (vals).end()), reverse((vals).begin(), (vals).end());
  cout << vals[0].second.first + 1 << " " << vals[1].second.first + 1 << "\n";
  cout << vals[0].second.second + 1 << " " << vals[1].second.second + 1 << "\n";
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  if (argc > 1) {
    assert(freopen(argv[1], "r", stdin));
  }
  if (argc > 2) {
    assert(freopen(argv[2], "wb", stdout));
  }
  chemthan();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
