#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
const int maxn = 3e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int n, pos, A, B, C, D;
int head[maxn], to[maxn * 2], nxt[maxn * 2], tot;
int deep[maxn], mx1[maxn], mx2[maxn];
pair<int, int> res;
inline void add_edge(int u, int v) {
  ++tot;
  to[tot] = v;
  nxt[tot] = head[u];
  head[u] = tot;
  ++tot;
  to[tot] = u;
  nxt[tot] = head[v];
  head[v] = tot;
}
void dfs(int u, int f) {
  deep[u] = deep[f] + 1;
  mx1[u] = u;
  int sz = 0;
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == f) continue;
    dfs(v, u);
    sz++;
    if (deep[mx1[v]] > deep[mx1[u]])
      swap(mx1[u], mx2[u]), mx1[u] = mx1[v];
    else if (deep[mx1[v]] > deep[mx2[u]])
      mx2[u] = mx1[v];
  }
  if (sz > 1) {
    pair<int, int> tp =
        pair<int, int>(deep[u], deep[mx1[u]] + deep[mx2[u]] - 2 * deep[u]);
    if (res < tp) res = tp, pos = u;
  }
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) add_edge(read(), read());
  dfs(1, 0);
  A = mx1[pos], C = mx2[pos];
  res.first = res.second = 0;
  dfs(pos, 0);
  B = mx1[pos], D = mx2[pos];
  printf("%d %d\n%d %d\n", A, B, C, D);
}
