Under construction

Still being built. Things may change

The Catcher in the Rye

Time limit1sMemory limit512 MB

Summary
Given a rectangle split into three vertical strips with different travel speeds, find the fastest route from the bottom-left to the top-right corner.
Level

Hard8 of 10

Topics
Geometry, Binary search, Math, Implementation
Solved
No attempts yet

Problem

As an experienced jogger, you decided to take a shortcut through a rectangular grain field, divided into three vertical patches full of rye, wheat and barley, respectively. You want to travel from its bottom left corner to the top right corner.

The proper jogging technique varies depending on which sort of grain you are trodding. Therefore, you will be going through the patches with three possibly different velocities. You may plan your route any way you wish (but without leaving the field).

Find the minimal time needed to get to the top right corner of the field from the bottom left corner.

Input

The first line of input contains the number of test cases zz (1≤z≤10 0001 \leq z \leq 10\,000). The descriptions of the test cases follow.

Each test case is given on a single line containing seven integers h,a,b,c,v_a,v_b,v_ch, a, b, c, v\_a, v\_b, v\_c (1≤h,a,b,c,v_a,v_b,v_c≤1051 \leq h, a, b, c, v\_a, v\_b, v\_c \leq 10^5): the height of the rectangular field, the widths of the patches, and the allowed velocities in these patches. Velocity vv means that you travel exactly vv units of distance per time unit.

Output

For each test case, output the total time needed to get from the bottom left corner to the top right one.

Your answer will be accepted if it differs from the correct one by no more than 10−310^{-3}.

Examples1

  1. Example 1

    Input
    2
    10 3 4 3 1 1 1
    21 5 12 4 4 3 4
    
    Expected output
    14.14213562
    8.75