Stacking Curvy Blocks

No attempts yetTime limit2sMemory limit256 MB

Problem

You are doing construction work, and to save money you bought discounted irregular blocks. Each irregular block is rectangular except for one edge, which is curvy. You wedge the irregular blocks between stacks of ordinary blocks so they cannot slide sideways or rotate. The lower irregular block sits with its curvy edge pointing up, and the one above it sits with its curvy edge pointing down. The upper block is lowered straight down until it just touches the lower one.

You want to know how well the two blocks fit together. At the moment the upper block just touches the lower one, the fit quality is the largest vertical gap between the upper edge of the bottom block and the lower edge of the top block.

Every block is one unit wide. Both curvy edges are cubic polynomials in xx, with the left edge of a block at x=0x = 0 and the right edge at x=1x = 1.

Input

The input holds several test cases and ends at end of file. There are at most 500 test cases.

Each test case is two lines, and each line holds four real numbers.

The first line gives b0b_0 b1b_1 b2b_2 b3b_3. The upper edge of the bottom block has the shape of b0+b1x+b2x2+b3x3b_0 + b_1 x + b_2 x^2 + b_3 x^3 for 0x10 \le x \le 1.

The second line gives t0t_0 t1t_1 t2t_2 t3t_3. The lower edge of the top block has the shape of t0+t1x+t2x2+t3x3t_0 + t_1 x + t_2 x^2 + t_3 x^3 for 0x10 \le x \le 1.

No input value has magnitude greater than 50000.

Output

For each test case, print the fit quality on its own line.

Round the value to six digits after the decimal point and always print all six digits, even when they are zero. A value of 3 prints as 3.000000.

No test case has an answer sitting on a boundary where the sixth digit could round either way.