#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct CLANNAD {
  int to, nxt;
} a[N << 1];
int cnt = 0, head[N];
inline void add(int u, int v) {
  a[++cnt].to = v;
  a[cnt].nxt = head[u];
  head[u] = cnt;
}
int dep[N], fir[N], sec[N], root;
pair<int, int> Max;
void dfs(int x, int fa) {
  dep[x] = dep[fa] + 1;
  int son = 0;
  for (int i = head[x]; i; i = a[i].nxt) {
    int to = a[i].to;
    if (to != fa) {
      dfs(to, x);
      son++;
      if (dep[fir[to]] > dep[fir[x]])
        sec[x] = fir[x], fir[x] = fir[to];
      else if (dep[fir[to]] > dep[sec[x]])
        sec[x] = fir[to];
    }
  }
  if (!son)
    fir[x] = x;
  else if (son >= 2) {
    pair<int, int> t = make_pair(dep[x], dep[fir[x]] + dep[sec[x]]);
    if (t > Max) Max = t, root = x;
  }
}
int main() {
  int n, x, y;
  cin >> n;
  for (int i = 1; i < n; i++) scanf("%d%d", &x, &y), add(x, y), add(y, x);
  Max = make_pair(0, 0);
  dfs(1, 0);
  int ans1 = fir[root], ans2 = sec[root];
  memset(fir, 0, sizeof(fir));
  memset(sec, 0, sizeof(sec));
  Max = make_pair(0, 0);
  dfs(root, 0);
  int ans3 = fir[root], ans4 = sec[root];
  printf("%d %d\n%d %d", ans1, ans3, ans2, ans4);
  return 0;
}
