#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2e5 + 25;
vector<int> v[MaxN];
bool deleted[MaxN];
int pr[MaxN];
int n;
vector<pair<int, int> > best[MaxN];
int val[MaxN];
int dist[MaxN];
pair<int, int> path[MaxN];
void dfs(int x, int p = 0) {
  if (deleted[x]) return;
  pr[x] = p;
  dist[x] = 1 + dist[p];
  for (int to : v[x])
    if (to != p) dfs(to, x);
}
int getFarthest(int x) {
  dfs(x);
  int res = x;
  for (int i = 1; i <= n; ++i)
    if (!deleted[i])
      if (dist[i] > dist[res]) res = i;
  return res;
}
struct T {
  int u, v;
  int len1, len2;
  T() { u = v = len1 = len2 = 0; }
  T(int u, int v, int len1, int len2) : u(u), v(v), len1(len1), len2(len2) {}
  bool operator<(const T& oth) const {
    if (len1 != oth.len1) return len1 < oth.len1;
    if (len2 != oth.len2) return len2 < oth.len2;
    if (u != oth.u) return u < oth.u;
    return v < oth.v;
  }
  bool operator>(const T& oth) const {
    if (len1 != oth.len1) return len1 > oth.len1;
    if (len2 != oth.len2) return len2 > oth.len2;
    if (u != oth.u) return u > oth.u;
    return v > oth.v;
  }
  bool operator==(const T& oth) const {
    return len1 == oth.len1 && len2 == oth.len2 && u == oth.u && v == oth.v;
  }
};
T getBest(int x, int p = 0) {
  if (deleted[x]) return T();
  T res;
  dist[x] = dist[p] + 1;
  for (int to : v[x])
    if (to != p) {
      T t = getBest(to, x);
      if (res < t) res = t;
    }
  if (!res.len2 && val[x])
    res = T(path[x].first, path[x].second, dist[x], val[x]);
  return res;
}
void solve(int x) {
  vector<T> t;
  for (int to : v[x]) t.push_back(getBest(to, x));
  sort(t.begin(), t.end());
  t.resize(unique(t.begin(), t.end()) - t.begin());
  reverse(t.begin(), t.end());
  assert(t.size() > 1);
  cout << t[0].u << ' ' << t[1].u << '\n';
  cout << t[0].v << ' ' << t[1].v << '\n';
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int root;
  for (int i = 1; i <= n; ++i)
    if (v[i].size() > 2) {
      dfs(i);
      root = i;
      break;
    }
  for (int i = 1; i <= n; ++i)
    if (v[i].size() == 1) {
      int x = i, d = 0;
      while (v[x].size() < 3) {
        ++d;
        deleted[x] = true;
        x = pr[x];
      }
      best[x].push_back({d, i});
    }
  for (int i = 1; i <= n; ++i)
    if (!deleted[i] && best[i].size() >= 2) {
      sort(best[i].begin(), best[i].end());
      reverse(best[i].begin(), best[i].end());
      val[i] = best[i][0].first + best[i][1].first;
      path[i] = {best[i][0].second, best[i][1].second};
    }
  int u = getFarthest(root);
  int v = getFarthest(u);
  vector<int> dtr;
  while (v != u) {
    dtr.push_back(v);
    v = pr[v];
  }
  dtr.push_back(u);
  if (dtr.size() == 2) {
    assert(dtr[0] != dtr[1]);
    cout << path[dtr[0]].first << ' ' << path[dtr[1]].first << '\n';
    cout << path[dtr[0]].second << ' ' << path[dtr[1]].second << '\n';
  } else {
    root = dtr[dtr.size() / 2];
    solve(root);
  }
  return 0;
}
