Bus Wireless Network Bandwidth

No attempts yetTime limit1sMemory limit128 MB

Problem

One amenity being added to buses and trains to attract or retain riders is a wireless network. Commuters can get work done while traveling, or browse the Internet just like at home. Of course, the more riders use the service, the less bandwidth is left for any one person, making it a little less attractive. Wouldn't it be nice if, before downloading a big file, you knew who boards and leaves the bus and when, so you could compute exactly how much bandwidth you will get during your ride?

Write a program to compute this. You are given the following data.

  1. The bus line: how many stops there are, and how many seconds it takes to travel between each pair of adjacent stops.
  2. The wireless network: the total available bandwidth is 1 megabyte per second. For each seat $i$ you are given the proportion $a_i$ of bandwidth that the seat commands. If $S$ is the set of occupied seats, then seat $i \in S$ receives $\dfrac{a_i}{\sum_{j \in S} a_j}$ of the bandwidth. All proportions $a_i$ for different seats are distinct. For example, suppose there are three seats with proportions 3, 2, 1. If only the first two seats are occupied, the person in the first seat gets $3/5 = 60%$ of the bandwidth and the other gets $2/5 = 40%$. If all three seats are occupied, the first person gets $3/6 = 50%$, the second $2/6 \approx 33.333%$, and the third $1/6 \approx 16.667%$.
  3. The passengers: at which stops each passenger (including you) boards and gets off. At any stop, everyone getting off leaves before anyone boarding gets on. When boarding, a passenger always takes the best available seat (the highest proportion) and never switches seats later, even if a better seat becomes free. If the bus is full, the passenger cannot board (this may include you). If several passengers board at the same stop, they try in the order listed in the input.

Input

The first line contains the number of data sets $K$. Then $K$ data sets follow, each in the form below.

The first line contains four integers $n, m, p, y$. Here $n$ is the number of bus stops ($2 \le n \le 100$), $m$ is the number of seats ($1 \le m \le 100$), $p$ is the number of passengers, and $y$ ($1 \le y \le p$) is your passenger number.

The next line contains $n-1$ integers giving the travel time in seconds from stop $i$ to stop $i+1$. The following line contains $m$ non-negative integers giving the proportion $a_i$ commanded by seat $i$.

Then $p$ lines follow, one per passenger $j$, each with two integers: the stop $s_j$ where the passenger boards and the stop $t_j > s_j$ where the passenger gets off. Passengers are sorted by non-decreasing boarding stop $s_j$.

Output

For each data set, first print Data Set x: on its own line, where $x$ is the data set number. On the next line, print the total bandwidth in megabytes that you obtained, rounded to two decimals. Separate consecutive data sets with a single blank line.