#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
int n;
vector<vector<int>> g;
void dfs(vector<int> &d, int cur, int depth, int pre = -1) {
  d[cur] = depth;
  depth++;
  for (int v : g[cur]) {
    if (v == pre) continue;
    dfs(d, v, depth, cur);
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  --u;
  --v;
  g.resize(n);
  for (int(i) = 0; (i) < (n - 1); (i)++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> tdist(n), adist(n);
  dfs(tdist, u, 0);
  dfs(adist, v, 0);
  int goal = -1;
  int dist = -1;
  for (int(i) = 0; (i) < (n); (i)++) {
    int curdist = adist[i];
    if (tdist[i] < adist[i] && curdist >= dist) {
      goal = i;
      dist = curdist;
    }
  }
  dist--;
  cout << goal << endl;
  cout << dist << endl;
}
