Aerospace & Mechanical Engineering

No attempts yetTime limit1sMemory limit128 MB

Problem

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:

  • its weight $m_i \ge 0$ (kg),
  • the time $t_i \ge 0$ (seconds) for which it burns, and
  • the constant thrust $F_i \ge 0$ (in kg·m/s², where m stands for meters) it produces while burning.

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:

  1. $a = F/m$ — an object of mass $m$ under a force $F$ accelerates at $a = F/m$.
  2. In Earth's gravity field every object accelerates downward at a constant $g = 9.81$ m/s².
  3. If an object starts with velocity $v$ and accelerates at $a$, then after $t$ seconds it has travelled a distance $vt + \frac{1}{2}at^2$ and its new speed is $v + at$.

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.

Input

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:

  • One line with the number of stages $n$ (where $1 \le n \le 30$) and the weight $M$ of the rocket body, a floating-point number strictly greater than $0$.
  • Then $n$ lines, each containing three non-negative floating-point numbers $m_i\ t_i\ F_i$ that describe one stage. The rocket's initial total weight is therefore $M + \sum_i m_i$.

Output

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.