Do you know Lotto? Lotto is a game of probability. Six numbers are drawn from a range of numbers (such as 42, 47, 47, 49, 51, and 54). Michigan, for instance, has a 6-out-of-47 game (6/47), meaning that six numbers are drawn from possible 47. Florida's Lotto is 6/53, meaning that six numbers are drawn from a possible 53.
To play Lotto, indicate your six chosen numbers by marking the numbered squares on a play slip. Then take the play slip to a lottery retailer (or agent). The retailer enters your selection in the on-line terminal, which produces your game ticket. The ticket, not the play slip, is the official receipt and must be presented and validated in the event of a win. Always check to make sure that the correct date and numbers are on the game ticket before you leave. Lottery agents are found in convenience stores, gas stations, and grocery stores.
The cost for one chance at Lotto is still $1 in many states. So for one chance, or play, at Lotto, you would pay $1. For five plays -- that is, to play five sets of numbers--you would pay $5. Illinois offers a bargain: two plays for $1.
Typically, Lotto drawings are held twice a week, usually on Wednesday and Saturday nights. However, this may not be true for every state.
The lottery officials use special ball-drawing machines, and the balls are numbered. The machine randomly shoots out six selected balls; these balls display the winning numbers for that evening's lottery drawing. If all six of your numbers exactly match the numbers drawn, you win the jackpot. In Lotto, your numbers don't need to be listed in any particular order, as long as they match those drawn. (taken from http://entertainment.howstuffworks.com/how-to-play-the-lottery1.htm)
In most case of lottery they don't draw same number, but in our problem here same number are allowed. So here, you can play number "42 42 45 45 45" which is not allowed in common lottos.
They say there's more chance of you getting hit by a car on your way to buy a lotto ticket than the chance of winning one. Is the probability to win really that small? You are about to help me find out.
Input starts with an integer T (1 <= T <= 10), the number of test cases. T input blocks follows. Each input blocks starts with an integer M (1 <= M <= 50), meaning that the game involves M distinct numbers particularly from 1 to M. You don't know how the ball-drawing machine works, but you do know that for there is a constant probability for each number to pop up. The second line of each input blocks will consists of M real-numbers P1, P2, P3, P4, ..., PM, where Pi denotes the probability of ball with number i to pop-up. You can safely assume that the total probability is equal to 1.
The third line of input is an integer Q (1 <= Q <= 100), the number of queries. Q lines follow with each line begins with an integer N (1 <= N <= M). So if N is 6, you are playing 6-out-of-M game in this particular query.N numbers follows, those are your chosen number. You are to determine what is the probability of that number winning the lottery. Since the probabilities can be very low, output them in scientific notation: a x 10^bwhere a should be between 1.00000 and 9.99999, inclusive. Output a in 5 decimal places.
For each query, you are to determine the probability of that number winning the lottery.