#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, h[N], x, y, x2, y2;
vector<int> g[N], child[N];
vector<pair<int, int> > buff;
bool leaf[N];
void dfs(int u, int p) {
  for (auto v : g[u]) {
    if (v == p) continue;
    h[v] = h[u] + 1;
    child[u].push_back(v);
    dfs(v, u);
  }
}
void redfs(int u, int p) {
  leaf[u] = true;
  for (auto v : child[u]) {
    if (v == p) continue;
    leaf[u] = false;
    h[v] = h[u] + 1;
    redfs(v, u);
  }
  if (leaf[u]) buff.push_back({h[u], u});
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 1);
  int Max = 0;
  vector<int> vec;
  for (int i = 1; i <= n; i++) {
    if (child[i].size() >= 2) {
      if (h[i] > Max) {
        Max = h[i];
        vec.clear();
        vec.push_back(i);
      } else if (h[i] == Max)
        vec.push_back(i);
    }
  }
  Max = 0;
  memset(h, 0, sizeof(h));
  for (auto i : vec) {
    buff.clear();
    redfs(i, i);
    sort(buff.begin(), buff.end(), greater<pair<int, int> >());
    if (buff[0].first + buff[1].first > Max) {
      Max = buff[0].first + buff[1].first;
      x = buff[0].second;
      y = buff[1].second;
    }
  }
  for (int i = 1; i <= n; i++) child[i].clear();
  vec.clear();
  Max = 0;
  memset(h, 0, sizeof(h));
  dfs(x, x);
  for (int i = 1; i <= n; i++) {
    if (child[i].size() >= 2) {
      if (h[i] > Max) {
        Max = h[i];
        vec.clear();
        vec.push_back(i);
      } else if (h[i] == Max)
        vec.push_back(i);
    }
  }
  Max = 0;
  memset(h, 0, sizeof(h));
  for (auto i : vec) {
    buff.clear();
    redfs(i, i);
    sort(buff.begin(), buff.end(), greater<pair<int, int> >());
    if (buff[0].first + buff[1].first > Max) {
      Max = buff[0].first + buff[1].first;
      x2 = buff[0].second;
      y2 = buff[1].second;
    }
  }
  printf("%d %d\n%d %d", x, y2, x2, y);
  return 0;
}
