Runalidi has prepared snacks for Dadas, who is invited to the party. The snacks are numbered from to .
Dadas considers the snacks in order from to and decides once whether to eat each snack. The base probability of eating snack is .
Dadas's fullness is an integer from to and is initially . Let be the fullness immediately before considering snack . Regardless of the earlier outcomes, if they leave the current fullness at , the conditional probability of eating snack is
The probability of not eating it is one minus this value. Immediately after the decision, update the fullness as follows.
Thus, for a fixed base probability, greater fullness never increases the eating probability, and the actual probability never exceeds the base probability.
There are questions, each consisting of two integers . Find the expected number of snacks Dadas eats among snacks through , inclusive, during the entire process.
Every question refers to the same random process that begins with fullness zero and considers snacks through . Expectations are taken before the process starts. Fullness is not reset at the beginning of a queried interval. Questions do not affect the process, and their order does not change any answer.
The first line contains the number of snacks and the number of questions . The second line contains the base probabilities , separated by spaces. Each is written as or , where each is a decimal digit, so exactly two digits appear after the decimal point. Each of the next lines contains the two integers of one question.
Print one answer per line, in question order. An answer is accepted if its absolute or relative error is at most .
The probabilities of eating the three snacks are , , and , respectively. The second question also refers to the entire process; fullness is not reset at snack .
Snacks and are never eaten. Snack is eaten with probability , and snack is always eaten.