Weather reporting is a tough job. Most of time, it is too hard to predict whether it will rain 2 weeks later even with the most powerful computer system since the atmosphere is a typical chaos system.
Modeling is a typical way to solve such a complex system. In today’s case, we check whether it rains for the past 5 days and determine the probability that the 6th day rains. You are given the rainfall probability of the 1st, 2nd, 3rd, 4th, and 5th day, and have to answer the rainfall probability of the Nth day.
The predicted rainfall probability is a linear combination of the past 5 days. i.e., the rainfall probability of the Nth day:
P(N) = a1×P(N-5) + a2×P(N-4) + a3×P(N-3) + a4×P(N-2) + a5×P(N-1).
Given the number N, please answer the corresponding rainfall probability P(N) of the Nth day.
The first line of input contains a positive integer T, T ≤ 10, which is the number of cases.
For each case, there are 3 lines.
There are 5 non-negative real numbers in the first line, denote the rainfall probability of day 1, day 2, day 3, day 4, and day 5. All probabilities are between 0.0 and 1.0.
The second line also contains 5 non-negative real numbers, which are a1, a2, a3, a4, a5. a1 + a2 + a3 + a4 + a5 = 1.0
There is only one integer N, 1 ≤ N ≤ 100, denoting the Nth day.
For each input case, output a real number with one digit after the decimal point as P(N).