The famous thief Matthew is robbing a jewellery store and has his hands on
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
Input Specification
The first line will contain two integers,
The next
The next
Output Specification
For each question, print out one integer on its own line: The beauty of the -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