Cover Up

Time limit1sMemory limit128 MB

Problem

A popular game show has a game in which a contestant guesses a multi-digit number (the price of a new car) one digit at a time. For each digit there are several numbers to choose from (say two for the first digit, three for the second, and so on), and exactly one of them is correct.

On each turn the contestant selects one number for every digit that is not yet correct, choosing only among the numbers not already picked for that digit, and is then told which selections are correct. If at least one new digit is correct this turn, the contestant may guess again for all still-incorrect digits. The contestant keeps guessing as long as every turn produces at least one new correct digit. The game ends when either all digits are correct (a win) or a turn produces no new correct digit (a loss).

For each digit, some of the choices are marked as known candidates. If a digit offers $m$ choices of which $l$ are known candidates, and the probability that the correct number is one of the known candidates is $p$, then each known candidate is equally likely to be correct (probability $p/l$ each) and each of the other $m-l$ choices is equally likely to be correct (probability $(1-p)/(m-l)$ each). For example, if a digit has five choices of which two are known candidates carrying a combined $70%$ chance, then each known candidate has a $35%$ chance and each of the other three has a $10%$ chance.

Determine the probability of winning the game when the contestant uses an optimal strategy for choosing numbers.

Input

Each test case consists of two lines. The first is $n$, the number of digits in the number to be guessed; the maximum value of $n$ is $5$. The second line contains $n$ triplets of the form $m\ l\ p$, where $m$ is the number of choices for a digit, $l$ is the number of known candidates, and $p$ is the probability that one of the known candidates is correct. In all cases $0 \le l < m \le 10$ and $0.0 \le p \le 1.0$. Whenever $l = 0$ (there are no known candidates), $p$ is always $0.0$. A line containing a single $0$ terminates the input.

Output

For each test case, output the probability of winning using an optimal strategy. All probabilities should be rounded to the nearest thousandth, and trailing zeros should not be output. (A $100%$ chance of winning should be output as $1$.)