lala-schumacher-and-asphalt

The problem statement has been updated. Notice the order of inputs.

Lala is an Asphalt champ. His car is stuck in an infinite city at (0,0).The city has vertical streets located at every integer X value and horizontal streets located at every Y value. He has to reach finishing spot in minimum time.There are nitro boosters in the city and their locations are (NX[i], NY[i]).The boosters are infinite i.e. they last forever.It takes normalTime seconds to drive along the street to proceed to a horizontally or vertically adjacent intersection without booster and it takes nitroTime seconds with boosters.

Print the least amount of time it will take him to reach finishing spot located at (fx,fy).

Input:

t: testcases

Each testcase contains 5 lines

n : number of boosts

A line containing array NX[]

A line containing array NY[]

fx and fy

normalTime and nitroTime.

Output:

As specified in problem statement

Constraints:

1 ≤ t ≤ 1000

1 ≤ n ≤ 10^5

1 ≤ nitroTime,normalTime ≤ 1000

-10^6 ≤ fx,NX[i] ≤ 10^6

-10^6 ≤ fy,NY[i] ≤ 10^6

SAMPLE INPUT
1
2
-2 0
-2 -2
-4 -2
15 3

SAMPLE OUTPUT
42

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: