What’s the Time?

In a manufacturing industry, continuous chemical reaction occurs inside a processing unit. The unit is equivalent to a large tank with huge (you can consider infinite) capacity. There are several inlets and outlets. Each inlet or outlet has a certain capacity and period. For example, if an inlet has capacity 10 and period 5, it means in first 5 unit time, 10 unit chemicals enter into the processing unit in each unit time and in next 5 unit time, it is kept closed. Now consider in the start, the processing unit contains a particular amount of chemicals. The amount of chemicals will change with time inside the processing unit. We are interested to know the time when, the processing unit will reach a particular amount. Now a peculiar incident can occur — the processing unit is empty and at that time outlets are open. In that case, immergence reservoir will be used which will be again refilled when the chemicals will be available. Input Each input set will start with two positive integers N (1 ≤ N ≤ 12) and K where N denotes the number of inlets/outlets and K is the current amount inside the processing unit. It is followed by the period (At most 12) and capacity (Absolute value at most 100) of each openings. The capacity will be positive in case of inlets and it will be negative for outlets. The next line will contain the desired amount inside the processing unit. All inputs will be integers and there can be at most 5000 data sets. Input will be terminated with N = 0 and K = 0. Integer means 32-bit signed integer. Output For each test set, print the serial of output followed by a floating point number that indicates the minimum time by which the processing unit will contain the desired amount. If the processing unit never contains the desired unit, print ‘Impossible.’. See the sample input-output for more information. Sample Input 2 397 12 -35 6 25 67121 20 34 3 -3 100 Sample Output Case 1: Impossible. Case 2: 199.00000000