The famous thief Matthew is robbing a jewellery store and has his hands on jewels numbered from to . These jewels have all been attached together into one heavy clump of jewels with titanium wires to prevent anyone from stealing them all at once.
Fortunately, the thief has a specialized device that lets him separate exactly one jewel from the rest by cutting the connected wires. Through this process, the thief will split the heavy clump of jewels into some number of lighter clumps, which allows him to steal the rest of the jewels with the wires intact.
Out of each lighter clump, he will make exactly one beautiful necklace. A segment of the clump is a path where every jewel is used at most once. The thief values the beauty of the clump (and thus, the beauty of the necklace) as the number of jewels in the longest segment of jewels in that clump. Note that the longest segment may be the entire clump, in which case the thief will value the clump as the number of jewels in the clump.
Given the structure of the original clump of jewels, can you determine the most beautiful necklace given that the thief separated jewel ? The thief is curious, and will ask of these questions.
Input Specification
The first line will contain two integers, , the number of jewels, and the number of questions the thief will ask.
The next lines will each contain two integers, , indicating that jewels and are connected by a titanium wire. It is guaranteed that all the jewels are attached together with titanium wires.
The next lines will each contain two integers, .
Output Specification
For each question, print out one integer on its own line: The beauty of the most beautiful necklace if the thief separated jewel . If there are less than necklaces that are made if jewel is separated, output -1
.
Constraints
Subtask 1 [5%]
Subtask 2 [30%]
Subtask 3 [65%]
No additional constraints.
Sample Input 1
4 3
1 2
2 3
2 4
2 1
3 1
4 1
Sample Output 1
1
3
3
Sample Input 2
8 6
1 2
2 3
3 4
4 5
5 6
3 7
7 8
3 2
2 1
2 2
4 1
4 2
4 3
Sample Output 2
2
6
1
5
2
-1
Comments