So, it’s learning time!! Suppose a word consisting of only 0 and 1 is called good if there is no adjacent one in the word. We are asked to find good words of length n. Now how to solve this problem? Let’s get our hand dirty and try to find the number of good words for several values of n. Value of n Good Words Number of Good words 2 3 5 8 1 0,1 2 00, 01, 10 3 000, 001, 010, 100, 101 4 0000, 0001, 0010, 0100, 0101, 1000, 1001, 1010 So, do you find any pattern? The numbers looks like Fibonacci numbers and yes it is Fibonacci number sequence. But the question is why it turned out to be Fibonacci sequence? Suppose we put 0 at the first position. Our constraint is not to put two adjacent ones. So we may fill up the remaining n − 1 places as we like except the condition that there cannot be any adjacent ones. Now if we put 1 at the first position then? Well as we cannot put two adjacent ones, so the second position must be filled by a 0. And following the previous argument rest of the positions can be filled up by as we like except the condition of adjacent ones. So if we denote the number of good words of n length is Wn then Wn = W(n−1) + W(n−2) which is of course the recurrence formula of Fibonacci number. And the base cases of this sequence are almost same as Fibonacci number as well. When I gave this analysis to Mr. Oh he said, “Uh! Come on, this is a very naïve problem, if you are so much intelligent then solve this one: There are N islands and M bridges. All the bridges are setup between two islands and to pass a bridge you have to give toll of $1. The bridges are built in such a way that there is not more than one path among two islands. Now, you have to visit at least K different islands. You may choose starting island of your choice, but you have to visit at least K different islands in minimum cost. (Starting island is considered to be already visited)” Input The first line of input will contain T (≤ 10) denoting the number of cases. Each case starts with two integers N, M (1 ≤ N ≤ 10000, 0 ≤ M < N). Each of the next M lines contains two integers u v (1 ≤ u,v ≤ N, u ̸= v) meaning that there is a bridge between island u and v. No bridge will be reported more than once. The next line contains an integer q (1 ≤ q ≤ 10000) denoting the number of queries. Each of the next q lines contains one integer K (1 ≤ K ≤ 10000). Output For each case, print the case number first. Then for each query print the minimum amount of toll you need to pay to visit at least K different islands. If it is not possible, print ‘impossible’. Note: For case 1:
2/2 Sample Input 2 21 12 3 1 2 3 54 12 23 24 25 2 3 2 Sample Output Case 1: 0 1 impossible Case 2: 2 1