#P1294F. Three Paths on a Tree
Three Paths on a Tree
Description
You are given an unweighted tree with vertices. Recall that a tree is a connected undirected graph without cycles.
Your task is to choose three distinct vertices on this tree such that the number of edges which belong to at least one of the simple paths between and , and , or and is the maximum possible. See the notes section for a better understanding.
The simple path is the path that visits each vertex at most once.
The first line contains one integer number () — the number of vertices in the tree.
Next lines describe the edges of the tree in form (, , ). It is guaranteed that given graph is a tree.
In the first line print one integer — the maximum number of edges which belong to at least one of the simple paths between and , and , or and .
In the second line print three integers such that and .
If there are several answers, you can print any.
Input
The first line contains one integer number () — the number of vertices in the tree.
Next lines describe the edges of the tree in form (, , ). It is guaranteed that given graph is a tree.
Output
In the first line print one integer — the maximum number of edges which belong to at least one of the simple paths between and , and , or and .
In the second line print three integers such that and .
If there are several answers, you can print any.
Samples
Note
The picture corresponding to the first example (and another one correct answer):
If you choose vertices then the path between and consists of edges , the path between and consists of edges and the path between and consists of edges . The union of these paths is so the answer is . It can be shown that there is no better answer.