
The CS Nerd has a mysterious package that he wants to deliver to the girl at school.
There are
In order to pass the package to the girl, the person who currently has the mysterious package can pass the package to another student in the same class or hold on to the package to pass on in future classes.
However, the CS Nerd is incredibly suspicious of people and would like to minimize the number of passes made in order to complete the transaction (note that giving the package to the girl also counts as one pass). He would also like for the package to be delivered to the girl as early as possible, but he prioritizes a minimal number of passes. Can you help him determine the minimum number of passes necessary and the earliest possible period when the girl will receive the package?
Input Specification
The first line of input will contain
The next line of input will contain two space-separated integers, the IDs of the CS nerd and the girl, respectively. It is guaranteed that these two IDs will appear in at least one class.
The first line of the
The next line of the
Output Specification
On separate lines, output two integers. The first integer will be the number of passes required to deliver the package by the end of the day. The second integer will be the earliest possible period in which the girl receives the package if a minimal number of passes occurs.
If the girl cannot receive the package, output delivery failure
instead.
Sample Input 1
6
1 10
1 3
16 2 1
3 3
7 10 2
1 3
52 7 14
2 3
16 10 52
2 2
14 4
1 2
10 4
Sample Output 1
2
2
Explanation for Sample Output 1
The CS Nerd (student
Sample Input 2
3
30 5
1 5
6 30 10 1 42
2 3
5 8 29
1 4
29 31 2 8
Sample Output 2
delivery failure
Comments