Aerospace engineers love building things that fly — airplanes, rockets, and more. Once you have built a rocket and launched it, a natural question is: how high does it fly before it comes back down?
Here is our model. The rocket has $n$ stages, each essentially a fuel tank. A stage burns for a fixed amount of time; once it is empty it is discarded, so the rocket grows lighter as it sheds stages. After the last stage is discarded the rocket can no longer accelerate. The rocket body itself weighs $M > 0$ kilograms — the weight that remains after every stage has been shed.
For each stage $i$ you are given three quantities:
The fuel itself is treated as weightless, so while stage $i$ is burning the total mass stays constant and equals $M$ plus the weights of all stages that have not yet been discarded (stages $i, i+1, \dots, n$). The rocket is shot straight up; ignore wind, friction, and the weakening of gravity with altitude. The rocket starts at rest (velocity $0$ m/s) at height $0$, and the stages are used and discarded in the order $1, 2, \dots, n$.
You will need these physics formulas:
So while stage $i$ burns, the net upward acceleration is $a_i = F_i / \text{mass}_i - g$, applied for $t_i$ seconds; afterwards stage $i$ is discarded and the mass drops by $m_i$.
Compute the height of the rocket at the instant the last stage falls off. The inputs are always such that the rocket lifts off and does not crash into the ground before the last stage is discarded.
The first line contains an integer $K \ge 1$, the number of data sets in the file. It is followed by $K$ data sets, each of the following form:
For each data set, first output the line Data Set x: on a line by itself, where $x$ is the data set's number (counting from $1$). Then, on the next line, output the height at which the rocket was when the last stage fell off, rounded to exactly two decimals.