SP4951 BRII - Bridges! More bridges!

Description

Problem [BRIDGE](/problems/BRI/) has shown that you are able to build the cheap bridge through the river very quickly. Now you will not have problems with time limit. You will have problems with number of bridges. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP4951/e9352a0f83b11c38cbdcff5bc8480e06310542a9.png)

Input Format

There is a single positive integer _T_ on the first line of input. It stands for the number of test cases to follow. Each test case is exactly five lines, containing description of the route between two cities A and B, located on opposite sides of the rivers. _n a $ _{0} $ a $ _{1} $ a $ _{2} $ ... a $ _{n} $ h $ _{1} $ h $ _{2} $ ... h $ _{n} $ c s $ _{0} $ s $ _{1} $ s $ _{2} $ ... s $ _{n} $_ Here _n_ is the number of the rivers which are parallel to each other, _a $ _{i} $_ - the distances between rivers or between rivers and cities, _h $ _{i} $_ - the widths of the rivers, _c_ - the distance between A and B along the axis parallel to the river, _s $ _{i} $_ - the costs of the unit of the bridge through _i $ _{th} $_ river and _s $ _{0} $_ - the cost of the unit of the road. Example for _n_=2 you can see on the picture. All integers in input are positive and less than 50, except _c_ - it is less than 2000.

Output Format

For each test case your program should write a single number to the standard output, equal to the minimal total cost of the route between A and B, accurate up to two digits after the decimal dot.