Anna and Ivet toss coins. Anna will win the game after heads, and Ivet will win after tails (whichever happens first). They have coins, each with a probability of landing heads (and a probability of landing tails). They start tossing the first coin. Anna, who chose the rules, decided that the same coin will be used as long as it lands heads, and that after landing tails the next coin will be used. How likely will Anna win?
Input consists of several cases, each with , and the probabilities. You can suppose .
For every case, print the probability that Anna wins with 4 digits after the decimal point.
Input
1 1 0.7 2 1 0.7 9 2 0 1 9 1 0 1 3 0.9 0.7 0.8 4 3 0.9 0.7 0.8 1000 3 0.9 0.7 0.8
Output
0.7000 0.4900 1.0000 0.0000 0.9940 0.9255 0.0000