Downpayment

No attempts yetTime limit1sMemory limit256 MB

Problem

A large house costs a lot of money, so buying one usually requires a loan. Lenders offer many mortgage plans; for example, you may lock in the current interest rate for a fixed period. During that binding period you may not switch lenders or change your terms. When the period ends you may switch to new terms (paying a penalty) or begin a fresh period. The catch is that interest rates change from month to month.

In this problem we make the fanciful assumption that you own a crystal ball: you know in advance what every plan's interest rate will be in every future month. Using this knowledge, schedule the payments so that the total amount of money paid over the whole loan is as small as possible.

Each month the debt changes as follows.

  1. First, any penalty for changing terms is added to the debt. In the very first month you may pick any plan with no penalty.
  2. Then the interest on the current debt (which already includes the penalty just added) is added.

After both amounts are added, the debt is rounded down to two decimal places (toward zero). A fixed amount is then paid, reducing the debt by that amount. If the debt is smaller than the fixed amount, only the remaining debt is paid and the loan is fully repaid. You owe no penalty for finishing the loan while still inside a binding period.

Input

The first line contains an integer $N \le 50$, the number of test cases.

Each test case begins with a line holding an integer $m$ and two numbers $x$ and $y$ (each with at most two decimals), where $1 \le m \le 20$ is the number of loan plans, $1 \le x \le 1000000$ is the amount borrowed, and $1 \le y \le 10000$ is the fixed amount paid every month.

The next $m$ lines each contain one integer $l$ with $1 \le l \le 60$, the binding time in months of that plan.

The following $m$ lines each contain $m$ numbers (at most two decimals); entry $C(a, b) \ge 0$ is the cost of switching from plan $a$ to plan $b$, with $C(a, b) = C(b, a)$ and $C(a, a) = 0$.

Then a line contains an integer $t$, the number of months for which interest information is given. You may assume $t$ is large enough for the optimal solution.

The final $t$ lines each contain $m$ numbers (at most two decimals): the monthly interest rates, in percent, of every plan for that month.

You may assume the loan can always be fully repaid within 100 years, and that every input line is at most 255 characters long.

Output

For each test case output a line Test case u, followed by a line Total: s, where $s$ is the minimum possible total amount paid over the entire loan, printed with exactly two decimal places. Put exactly one space after each colon. The counter $u$ starts at 1.