Toxic Assets

No attempts yetTime limit1sMemory limit128 MB

Problem

One reason home foreclosures hit the economy so hard is that financial institutions invented mortgage-backed derivatives. The right to a stream of mortgage payments was packaged as an investment and sold to other investors in small chunks. Those chunks could then be mixed with other investments, repackaged, and sold again. As a result, the real worth of a derivative depends on underlying mortgages that are hard to trace. Once the value of the basic building blocks that every derivative rests on changes, it is far from obvious what your portfolio is now worth — you may have to follow a whole chain of derivatives.

We model this as follows. You own some basic investments, such as mortgages. Each basic investment was worth $1 before; you are told what one unit of it is worth now. On top of these there are derivatives. Every derivative is built from one or more basic investments or other derivatives: you are given the list of components together with the percentage each contributes (the percentages always add up to 1). Each derivative is built only from basic investments or from derivatives with a lower number, so there are no cycles. Finally, you are given the composition of your portfolio as percentages of the individual investments. Compute what one unit of your portfolio, which was worth $1 before, is worth now.

This model is a simplification; it is only our best understanding of what happens. In fact, part of why the economy struggled is that very few people truly understood how these derivatives work.

Input

The first line contains the number of data sets $K$. Each of the $K$ data sets has the following form.

The first line of a data set contains two integers $B$ and $D$: the number of basic investments ($1 \le B \le 100$) and the number of derivatives ($0 \le D \le 100$). The basic investments are numbered $1, \dots, B$ and the derivatives are numbered $B+1, \dots, B+D$.

The next line contains $B$ non-negative floating-point numbers: the current value of one unit of each basic investment, in order.

Then follow $D$ lines. The $d$-th of these lines contains $B + d - 1$ non-negative floating-point numbers describing what percentage of derivative $B + d$ is made up of investments $1, \dots, B + d - 1$. These numbers always add up to 1, and no derivative ever contains any part of a derivative with a higher number.

The last line of the data set contains $B + D$ non-negative floating-point numbers that add up to 1: the percentage of your portfolio made up of each investment.

Output

For each data set, output the line Data Set x: on its own, where $x$ is the number of the data set. On the following line, output the current value of one unit of your portfolio, rounded to two decimals. Separate consecutive data sets with one blank line.