Kiddie Pool

Choose on-off times for sources with different flow rates and temperatures to collect exactly V liters at temperature X in the least time.

Medium7Binary searchGreedyMathNo attempts yetTime limit5sMemory limit512 MB

Problem

A kiddie pool is a big container you fill with water so that small children can play in it.

You have NN different water sources. Source ii produces water at a rate of RiR_i liters per second and at a temperature of CiC_i degrees. All sources start off. Each source can be switched on only once and switched off only once, and switching takes no time. Several sources can be on at the same time.

The pool holds any amount of water, but you want to fill it to a volume of exactly VV liters at a temperature of exactly XX degrees, as quickly as possible. If you turn the sources on and off optimally, what is the minimum number of seconds it takes? You do not have to use every source.

In this problem, combining water of volume V0V_0 and temperature X0X_0 with water of volume V1V_1 and temperature X1X_1 instantaneously produces water of volume V0+V1V_0 + V_1 and temperature (V0X0+V1X1)/(V0+V1)(V_0 X_0 + V_1 X_1) / (V_0 + V_1). For example, combining 5 liters at 10 degrees with 10 liters at 40 degrees gives 15 liters at 30 degrees. Assume water neither heats nor cools over time except by being combined with other water.

Input

The first line contains the number of test cases TT. TT test cases follow.

The first line of each test case contains three space separated numbers NN, VV, and XX. NN is an integer and VV and XX are real numbers. The next NN lines each contain the flow rate RiR_i and the temperature CiC_i of source ii, separated by a space. Volume is in liters, flow rate is in liters per second, and temperature is in degrees Celsius.

Every real number is given with exactly four decimal places.

Limits

  • 1T1001 \le T \le 100
  • 1N1001 \le N \le 100
  • 0.0001V10000.00.0001 \le V \le 10000.0
  • 0.1X99.90.1 \le X \le 99.9
  • 0.0001Ri1000.00.0001 \le R_i \le 1000.0
  • 0.1Ci99.90.1 \le C_i \le 99.9

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the minimum number of seconds needed to fill the pool to the target volume at the target temperature. If the given input makes that impossible, print IMPOSSIBLE in place of yy.

Print yy with exactly nine digits after the decimal point. Round at the tenth digit, and round up when the value is exactly halfway. An answer of 50 seconds is printed as 50.000000000.

Notes on the samples

In Case #1 of the first sample, the only source is already at the target temperature. The best plan is to switch it on immediately and let it run until the pool holds 10 liters. It delivers 0.2 liters per second, so this takes 50 seconds.

In Case #2, one optimal plan is to run the first source for 207221.843687375 seconds and also switch the second source on about 0.092778156 seconds before the end.

In Case #3, both sources are colder than the target temperature, so the target cannot be reached.