#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 5;
const int mod = 998244353;
int n, res, tot = 0, head[N], dep[N], fir[N], sec[N];
pair<int, int> mx(0, 0);
struct Edge {
  int to, nxt;
} e[N << 1];
inline void add(int fro, int to) {
  e[++tot].to = to;
  e[tot].nxt = head[fro];
  head[fro] = tot;
}
void dfs(int x, int fat, int depth) {
  dep[x] = depth;
  int son = 0;
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (y == fat) continue;
    dfs(y, x, depth + 1);
    ++son;
    if (dep[fir[y]] > dep[fir[x]])
      sec[x] = fir[x], fir[x] = fir[y];
    else if (dep[fir[y]] > dep[sec[x]])
      sec[x] = fir[y];
  }
  if (!son) fir[x] = x;
  if (son >= 2) {
    pair<int, int> tmp = pair<int, int>(dep[x], dep[fir[x]] + dep[sec[x]]);
    if (tmp > mx) mx = tmp, res = x;
  }
}
int main() {
  scanf("%d", &n);
  for (int x, y, i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0, 1);
  int ans1 = fir[res], ans2 = sec[res];
  mx = pair<int, int>(0, 0);
  memset(fir, 0, sizeof(fir));
  memset(sec, 0, sizeof(sec));
  dfs(res, 0, 1);
  int ans3 = fir[res], ans4 = sec[res];
  printf("%d %d\n%d %d\n", ans1, ans3, ans2, ans4);
  return 0;
}
