#include <bits/stdc++.h>
using namespace std;
int n, A, B, C, D, pos, dep[200010], f[200010], g[200010];
int k, la[200010], ff[200010 * 2];
struct info {
  int x, y;
  bool operator<(const info &p) const {
    return x < p.x || (x == p.x && y < p.y);
  }
} res;
struct node {
  int a, b;
} e[200010 * 2];
void add(int a, int b) {
  e[++k] = (node){a, b};
  ff[k] = la[a];
  la[a] = k;
  e[++k] = (node){b, a};
  ff[k] = la[b];
  la[b] = k;
}
void dfs(int x, int fa) {
  int cnt = 0;
  f[x] = g[x] = 0;
  for (int a = la[x]; a; a = ff[a]) {
    if (e[a].b == fa) continue;
    cnt++;
    dep[e[a].b] = dep[x] + 1;
    dfs(e[a].b, x);
    if (dep[f[e[a].b]] > dep[f[x]])
      g[x] = f[x], f[x] = f[e[a].b];
    else if (dep[f[e[a].b]] > dep[g[x]])
      g[x] = f[e[a].b];
  }
  if (!cnt) f[x] = x;
  if (cnt >= 2) {
    info tmp = (info){dep[x], dep[f[x]] + dep[g[x]] - dep[x] * 2};
    if (res < tmp) res = tmp, pos = x;
  }
}
int main() {
  int a, b;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d%d", &a, &b), add(a, b);
  dep[1] = 0;
  res = (info){0, 0};
  dfs(1, 0);
  A = f[pos];
  C = g[pos];
  dep[pos] = 0;
  res = (info){0, 0};
  dfs(pos, 0);
  B = f[pos];
  D = g[pos];
  printf("%d %d\n%d %d\n", A, B, C, D);
  return 0;
}
