Hill Driving

You’re driving your car in the local hills and returning to your home town. You’d like to get back as quickly as possible; however, you notice that you don’t have much fuel left. You know the most efficient route to take. Some parts of this route go downhill, and some go uphill. The different parts have different lengths and slopes. How quickly can you reach home with the little fuel you have left?

We will assume a very simple model for the fuel consumption of your car. Fuel consumption (per unit distance travelled) will increase linearly with your driving speed $v$. However, there is an offset which depends on the slope $s$ of the hill. For example, when going downhill you might be able to go at $10$ km/h without expending any fuel; on the other hand, if you were travelling that road uphill, you might expend fuel as if you were driving $10$ km/h faster on a flat road. More specifically, the car’s fuel consumption $c$ in liters per kilometer is given by

\begin{equation} c = \max (0,\alpha \, v + \beta \, s), \end{equation}

where $\alpha $ is the standard fuel consumption rate on a flat road, $v$ is your speed in km/h, $s$ is the slope of the road, and $\beta $ is a positive constant. Acceleration and deceleration do not cost fuel and can be done instantaneously.

Note that your car has a maximum (safe) speed which cannot be exceeded.


On the first line a positive integer: the number of test cases, at most $10$. After that per test case:

  • One line with four real numbers $\alpha $ ($0.1\le \alpha \le 100$), $\beta $ ($0.1 \le \beta \le 100$), $v_{\rm max}$ ($10 \le v_{\rm max} \le 200$) and $f$ ($0 \le f \le 50$): the standard (flat road) fuel consumption rate of your car, the slope factor, the maximum speed of your car in km/h, and the amount of fuel you have left in liters, respectively.

  • One line with an integer $r$ ($1 \le r \le 10\, 000$): the number of road segments.

  • $r$ lines with two real numbers $x_ i$ and $y_ i$ ($1 \le x_ i \le 1\, 000$, $-1\, 000 \le y \le 1\, 000$) each: the horizontal distance and height change (both in meters) of the $i$-th road segment. Each road segment has constant slope.

All real numbers in the input have at most $5$ digits after the decimal point.


Per test case:

  • One line with a real number: the fastest time in hours in which you can reach town. It is guaranteed that if it is possible to reach town at all, it will always be possible in less than 24 hours. If it is impossible to reach town, the line must contain “IMPOSSIBLE” instead.

Your output should have a relative or absolute error of at most $10^{-6}$.

Sample Input 1 Sample Output 1
10.0 1.0 150 0.0
100.0 -100.0
10.0 100.0 150 1.0
100 0
100 100
0.5 0.1 100 10
1000 0
100 10
100 -10