#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 10;
pair<int, int> fir[maxn], sec[maxn];
int readint() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
struct Node {
  int id, depth, tot;
  Node(int _id, int _depth, int _tot) : id(_id), depth(_depth), tot(_tot) {}
  Node() {}
  bool operator<(const Node &b) const {
    if (depth == b.depth)
      return tot < b.tot;
    else
      return depth < b.depth;
  }
};
vector<int> G[maxn];
Node best;
void dfs(int u, int fa, int dep) {
  int deg = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (G[u][i] == fa) continue;
    deg++;
    dfs(v, u, dep + 1);
    if (fir[v].first > fir[u].first) {
      swap(fir[u], sec[u]);
      fir[u] = fir[v];
    } else if (fir[v].first > sec[u].first) {
      sec[u] = fir[v];
    }
  }
  if (deg >= 2) best = max(best, Node(u, dep, fir[u].first + sec[u].first));
  if (deg == 0) {
    fir[u] = make_pair(dep, u);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  int u, v;
  for (int i = 1; i <= n - 1; i++) {
    cin >> u >> v;
    G[u].push_back(v), G[v].push_back(u);
  }
  best = Node(0, 0, 0);
  dfs(1, 0, 1);
  int p = best.id;
  int u1, v1, u2, v2;
  u1 = fir[p].second, v2 = sec[p].second;
  memset(fir, 0, sizeof(fir)), memset(sec, 0, sizeof(sec));
  best = Node(0, 0, 0);
  dfs(p, 0, 1);
  p = best.id;
  cout << u1 << " " << fir[p].second << endl;
  cout << sec[p].second << " " << v2 << endl;
  return 0;
}
