| Jar number | Volume (l) | Temperature (°C) |
|---|
| 0 | 45 | 23 |
| 1 | 20 | 40 |
| 2 | 67 | 22 |
| 3 | 109 | 11 |
| 4 | 9 | 56 |
This way, for example, you could pour jars 1, 2 and 3 into the pool, but not only jars 1 and 3.
The resulting total volume (assuming that the pool is large enough) would be 20 + 67 + 109 = 196 liters and the resulting temperature would be (20 × 40 + 67 × 22 + 109 × 11) / (20 + 67 +109) = 17.719388 °C.
The input format is as follows.
An integer in a single line which says the number of problems to solve. Then, for each problem:
For each problem, you have to print a line with two integers representing the first and the last jar to pour into the pool, minimizing the difference with respect to the target temperature.
If there is no way to fill at least half the pool without overflowing it with water within the acceptable temperature range, the line should be ‘Not possible’. If there are many optimal solutions, you have to use the jars with the lowest numbers.
Pool capacity is positive and jar water volumes are nonnegative integers. A chosen interval must have positive total volume. Ties are resolved by smaller first jar index, then smaller last jar index, using zero-based indices. Exact half capacity, exact full capacity, and temperature difference exactly five degrees are allowed.