import java.io.*;
import java.util.*;
public class Main {
public static class TreeNode {
TreeNode left;
int val;
TreeNode right;
public TreeNode(int val) {
this.val = val;
}
}
public static class Read {
StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public int read() throws IOException {
st.nextToken();
return (int) st.nval;
}
}
public static TreeNode root;
public static HashMap<Integer, TreeNode> nodeMap = new HashMap<>();
public static int depth;
public static int width;
public static void main(String[] args) throws IOException {
Read rd = new Read();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
int n = rd.read();
for (int i = 0; i < n - 1; i++) {
int u = rd.read();
int v = rd.read();
addNode(u, v);
}
int x = rd.read();
int y = rd.read();
int distance = findLCA(x, y);
bfs();
pw.println(depth);
pw.println(width);
pw.print(distance);
pw.close();
}
private static boolean findPath(TreeNode root, int target, ArrayList<TreeNode> path) {
if (root == null) {
return false;
}
path.add(root);
if (root.val == target) {
return true;
}
if (findPath(root.left, target, path) || findPath(root.right, target, path)) {
return true;
}
path.remove(path.size() - 1);
return false;
}
public static int findLCA(int x, int y) {
ArrayList<TreeNode> xPath = new ArrayList<>();
ArrayList<TreeNode> yPath = new ArrayList<>();
findPath(root, x, xPath);
findPath(root, y, yPath);
int i;
for (i = 0; i < Math.min(xPath.size(), yPath.size()); i++) {
if (xPath.get(i) != yPath.get(i)) break;
}
int xToLCALength = xPath.size() - i;
int yToLCALength = yPath.size() - i;
return (xToLCALength << 1) + yToLCALength;
}
public static void addNode(int u, int v) {
nodeMap.putIfAbsent(u, new TreeNode(u));
nodeMap.putIfAbsent(v, new TreeNode(v));
TreeNode parentNode = nodeMap.get(u);
TreeNode childNode = nodeMap.get(v);
if (root == null) {
root = parentNode;
}
if (parentNode.left == null) {
parentNode.left = childNode;
} else {
parentNode.right = childNode;
}
}
public static void bfs() {
Deque<TreeNode> queue = new ArrayDeque<>();
queue.offer(root);
while (!queue.isEmpty()) {
int size = queue.size();
width = Math.max(width, size);
for (int i = 0; i < size; i++) {
TreeNode poll = queue.poll();
if (poll.left != null) {
queue.offer(poll.left);
}
if (poll.right != null) {
queue.offer(poll.right);
}
}
depth++;
}
}
}