#include <bits/stdc++.h>
using namespace std;
const int MX = 200005;
int n, u, v, a[MX], b[MX], d[MX], na[MX], nb[MX];
pair<int, int> dis[MX], rec[MX];
pair<int, int> res, x, y;
vector<int> adj[MX];
bitset<MX> bs;
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
void insert(int u, int k, int l) {
  if (k >= a[u]) {
    b[u] = a[u];
    a[u] = k;
    nb[u] = na[u];
    na[u] = l;
  } else if (k >= b[u]) {
    b[u] = k;
    nb[u] = l;
  }
}
void bfs() {
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (adj[i].size() >= 3 && d[i] + 1 == adj[i].size()) {
      bs[i] = 1;
      q.push(i);
      rec[i] = pair<int, int>(na[i], nb[i]);
      dis[i] = pair<int, int>(1, a[i] + b[i]);
    }
  while (q.size()) {
    int u = q.front();
    pair<int, int> dd = dis[u] + pair<int, int>(1, 0);
    q.pop();
    for (int v : adj[u]) {
      if (rec[u] != rec[v] && res < dd + dis[v]) {
        res = dd + dis[v];
        x = rec[u];
        y = rec[v];
      }
      if (!bs[v]) {
        d[v]++;
        if (d[v] + 1 == adj[v].size()) {
          q.push(v);
          bs[v] = 1;
        }
        if (dis[v] < dd) {
          dis[v] = dd;
          rec[v] = rec[u];
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (adj[i].size() == 1) {
      int u = i, cn = 0;
      while (1) {
        if (adj[u].size() >= 3) {
          d[u]++;
          insert(u, cn, i);
          break;
        }
        cn++;
        bs[u] = 1;
        for (int v : adj[u])
          if (!bs[v]) {
            u = v;
            break;
          }
      }
    }
  bfs();
  cout << x.first << " " << y.second << '\n';
  cout << y.first << " " << x.second << '\n';
  return 0;
}
