#include <bits/stdc++.h>
using namespace std;
long long N, M, L;
long long ans = 0;
long long prohibitedArea;
pair<long long, long long> mx;
vector<bool> seen;
class dijkstra {
 public:
  long long N;
  vector<vector<pair<long long, long long> > > G;
  vector<long long> dist;
  vector<bool> used;
  vector<long long> prever;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      que;
  dijkstra(long long n = 4545) {
    N = n;
    G.assign(N, vector<pair<long long, long long> >());
    dist.assign(N, 11451419191919);
    used.assign(N, false);
    prever.assign(N, -1);
  }
  void addEdge(long long v, long long u, long long w = 1) {
    G[u].push_back(make_pair(v, w));
  }
  vector<long long> CalcDist(long long s) {
    que.push(make_pair(0, s));
    while (!que.empty()) {
      long long d = 0;
      long long t_v = 0;
      d = que.top().first;
      t_v = que.top().second;
      que.pop();
      if (used[t_v] == true) continue;
      used[t_v] = true;
      dist[t_v] = d;
      for (long long i = 0; i < G[t_v].size(); i++) {
        long long to = G[t_v][i].first;
        long long cost = d + G[t_v][i].second;
        if (dist[to] <= cost) continue;
        prever[to] = t_v;
        que.push(make_pair(cost, to));
        dist[to] = cost;
      }
    }
    return dist;
  }
  vector<long long> get_path(long long t) {
    vector<long long> path;
    for (; t != -1; t = prever[t]) {
      path.push_back(t);
    }
    return path;
  }
};
vector<vector<pair<long long, long long> > > dfsG;
void dfs(long long idx, long long from = -1, long long pathSize = 0) {
  seen[idx] = true;
  if (idx == prohibitedArea) {
    return;
  }
  if (mx.first < pathSize) {
    mx.first = pathSize;
    mx.second = idx;
  }
  for (long long i = 0; i < dfsG[idx].size(); i++) {
    long long to = dfsG[idx][i].first;
    if (seen[to] == true) {
      continue;
    }
    dfs(to, idx, pathSize + 1);
  }
  return;
}
int main() {
  cin >> N >> M >> L;
  dijkstra D1(N);
  dijkstra D2(N);
  dfsG.assign(N, vector<pair<long long, long long> >());
  for (long long i = 0; i < N - 1; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    D1.addEdge(u, v);
    D1.addEdge(v, u);
    D2.addEdge(u, v);
    D2.addEdge(v, u);
    dfsG[u].push_back(make_pair(v, 1));
    dfsG[v].push_back(make_pair(u, 1));
  }
  D1.CalcDist(M - 1);
  vector<long long> path = D1.get_path(L - 1);
  long long tmp = D1.dist[L - 1] / 2 + D1.dist[L - 1] % 2;
  long long ans = tmp;
  long long next_start = path[tmp];
  prohibitedArea = path[tmp - 1];
  cout << next_start << " " << prohibitedArea << endl;
  seen.assign(N, false);
  dfs(next_start);
  ans += mx.first - 1;
  cout << ans << endl;
}
