#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> g[200020];
int leaf[200020];
int d[200020];
void calc(int u, int pa = 0) {
  if (g[u].size() == 1) leaf[u] = 1;
  for (int v : g[u]) {
    if (v == pa) continue;
    d[v] = d[u] + 1;
    calc(v, u);
    leaf[u] += leaf[v];
  }
}
struct point {
  int id, d;
  point(int id = 0, int d = 0) : id(id), d(d) {}
  bool operator<(const point x) { return d < x.d; }
} p[200020][2];
int pa[200020];
vector<pair<pair<int, int>, pair<int, int> > > q;
void dfs(int u, int root = 0) {
  p[u][0].id = u;
  for (int v : g[u]) {
    if (v == pa[u]) continue;
    d[v] = d[u] + 1;
    pa[v] = u;
    dfs(v, root);
    point x = p[v][0];
    x.d++;
    if (p[u][1] < x) {
      p[u][1] = x;
      if (p[u][0] < p[u][1]) swap(p[u][1], p[u][0]);
    }
  }
  if (root && p[u][0].id && p[u][1].id && p[u][1].id != u)
    q.push_back(make_pair(pair<int, int>(d[u], p[u][0].d + p[u][1].d),
                          pair<int, int>(u, root)));
}
void again(int u, int root = 0) {
  p[u][0].id = u;
  for (int v : g[u]) {
    if (v == pa[u]) continue;
    if (u == root && leaf[v] > 1) continue;
    pa[v] = u;
    again(v, root);
    point x = p[v][0];
    x.d++;
    if (p[u][1] < x) {
      p[u][1] = x;
      if (p[u][0] < p[u][1]) swap(p[u][1], p[u][0]);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int rt = 0;
  for (int i = 1; i <= n; i++) {
    if (g[i].size() >= 3) {
      rt = i;
      break;
    }
  }
  assert(rt);
  calc(rt);
  int fi = 0;
  for (int i = 1; i <= n; i++)
    if (leaf[i] > 1 && d[i] > d[fi]) fi = i;
  d[fi] = 0;
  pa[fi] = 0;
  dfs(fi);
  int se = 0;
  for (int i = 1; i <= n; i++)
    if (leaf[i] > 1 && d[i] > d[se]) {
      se = i;
    }
  int maxd = d[se];
  int mid = se;
  while (d[mid] * 2 > maxd) mid = pa[mid];
  d[mid] = 0;
  pa[mid] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 2; j++) p[i][j] = point(0, 0);
  for (int x : g[mid])
    if (leaf[x] > 1) {
      pa[x] = mid;
      d[x] = 1;
      dfs(x, x);
    }
  again(mid, mid);
  if (p[mid][0].id && p[mid][1].id && p[mid][1].id != mid)
    q.push_back(make_pair(pair<int, int>(0, p[mid][0].d + p[mid][1].d),
                          pair<int, int>(mid, mid)));
  sort(q.begin(), q.end());
  assert(q.size() >= 2);
  int x = q.back().second.first;
  int y;
  for (int i = q.size() - 2; i >= 0; i--) {
    if (q[i].second.second != q.back().second.second) {
      y = q[i].second.first;
      break;
    }
  }
  printf("%d %d\n%d %d\n", p[y][0].id, p[x][0].id, p[y][1].id, p[x][1].id);
}
