Blocks&Balls

Given a container with fixed blocks and balls inside, find the water level where water volume v fills the region below that height.

Medium7Binary searchGeometryMathPrefix sumNo attempts yetTime limit2sMemory limit512 MB

Problem

A child on a space station plays with a toy called Blocks&Balls. The toy is one rectangular container together with several small rectangular blocks and several balls floating inside it. There is no gravity, so the blocks and the balls stay where they were placed instead of sinking to the bottom.

The child wonders how high the surface would rise after pouring water into the container. Water does not gather at the bottom in orbit, so the experiment is impossible up there, but the level can still be computed.

The base of the container is a rectangle of width ww and length ll, and the container is infinitely tall. The base sits at height 00. Every block is a rectangular box whose faces are parallel to the faces of the container. A block with center height zz, width aa, length bb and height cc occupies the heights from zc/2z - c/2 to z+c/2z + c/2, and a horizontal cut through it has area a×ba \times b. Every ball has center height zz and radius rr.

You pour water of volume vv. The water gathers from the bottom, and the blocks and the balls stay fixed, so the part of each object below the surface takes up room the water would otherwise fill. The water level hh is the height at which the volume between height 00 and height hh, minus the volume the blocks and the balls occupy inside that range, is exactly vv. Compute hh.

Input

The first line contains the number of test cases TT. (1T201 \le T \le 20)

The first line of each test case contains the real numbers ww, ll, vv and the integers mm, nn: the width of the container, its length, the volume of the poured water, the number of blocks and the number of balls. (0<w,l10000 < w, l \le 1000, 0<v10120 < v \le 10^{12}, 1m,n1000001 \le m, n \le 100\,000)

Each of the next mm lines contains the real numbers zz, aa, bb, cc of one block: the height of its center, its width, its length and its height. (0<aw0 < a \le w, 0<bl0 < b \le l, 0<c0 < c, zc/20z - c/2 \ge 0, z+c/2100000z + c/2 \le 100\,000)

Each of the next nn lines contains the real numbers zz, rr of one ball: the height of its center and its radius. (0<2rmin(w,l)0 < 2r \le \min(w, l), zr0z - r \ge 0, z+r100000z + r \le 100\,000)

Every real number is given with at most six digits after the decimal point. The input is always consistent: no two objects intersect, and every object fits inside the container. The sum of m+nm + n over all test cases is at most 200000200\,000.

Output

For each test case, print the water level on its own line, rounded to exactly six digits after the decimal point with the trailing digits written out. If the answer is exactly 33, print 3.000000.

If several values of hh satisfy the condition, print the smallest one. The water level never exceeds 10610^6, and the exact water level is always at least 10710^{-7} away from the midpoint of two neighboring multiples of 10610^{-6}, so the rounded value is unambiguous.