Automat#96

Automat

0.5 seconds
64 megabytes
Hard

Consider a device that must regulate its own temperature, ensuring it remains neither too high nor too low while performing its work. However, its temperature control mechanism has malfunctioned, and now the device operates as follows: every minute, a method of changing the temperature is chosen and applied, with each possible change selected at a specified probability, depending on the current temperature.

You are given the probabilities for each possible temperature change. Calculate the probability that the temperature remains within the specified range for a given period of time.

Input

The first line contains the number of test cases (1 \leq T \leq 20). Each test case begins with a line containing four integers , , , , where is the minimum allowed temperature, is the maximum allowed temperature, is the initial temperature, and is the device's operating time in minutes. 0 \leq A \leq B \leq 30, A \leq C \leq B, 0 \leq N \leq 30.

Each of the next B-A+1 lines contains non-negative integers summing to — the percentage probabilities for temperature changes of , , , , , , and degrees, respectively. The -th line (1 \leq K \leq B-A+1) describes these probabilities when the current temperature is A+K-1.

Output

Output lines in the format "Case #A: B", where is the test case number (starting from ), and is the required probability for that test case. Print the answer without rounding. It is guaranteed that the answer contains at most digits after the decimal point.

Examples

Example 1

Loading
Loading