Currency Exchange

No attempts yetTime limit1sMemory limit128 MB

Problem

When Isaac travels abroad — say, to France — he exchanges his US dollars for the local currency (French francs). An exchange rate is a real number: multiplying the number of dollars by the rate gives the number of francs. For example, if the exchange rate from US dollars to French francs is 4.817244.81724, then 1010 dollars becomes 48.172448.1724 francs.

You can only hold hundredths of a unit of currency, so every exchanged amount is rounded to the nearest hundredth, with .005.005 always rounded up to .01.01. Every exchange between any two currencies is rounded this way.

Some of Isaac's trips take him through several countries, exchanging the money of one foreign country directly for that of the next. When he finally comes home he exchanges whatever is left back into US dollars. Isaac wants to know how much of his unspent money is lost (or gained) to these exchange rates. Given the exchange rates and a sequence of trips, compute how many US dollars Isaac ends up with after each trip. Every trip starts and ends in US dollars.

Input

There are 55 countries, numbered 11 through 55; country 11 is the United States.

The first 55 lines describe the exchange-rate matrix. Line ii contains 55 real numbers; the jj-th number is the exchange rate from the currency of country ii to the currency of country jj. The rate from a country to itself is always 11.

Each of the following lines describes one trip in the form:

n c1 c2 … cn m

where 1n101 \le n \le 10 and each c1,,cnc_1, \dots, c_n is an integer from 22 to 55 giving, in order, the countries Isaac visits. The trip is therefore 1c1c2cn11 \to c_1 \to c_2 \to \dots \to c_n \to 1. The real number mm is the amount of US dollars Isaac starts the trip with.

A line whose first number is n=0n = 0 marks the end of the input; it contains no further numbers.

Output

For each trip, print one line with the number of US dollars Isaac has when he returns home, rounded to the nearest cent. Print the value in the usual way, with the cents shown after the decimal point and exactly two digits after it. If the amount is less than one dollar, print a 00 in the dollars place (for example, 0.99).