#t2. 魔法快递

魔法快递

Magic Delivery

Problem Description

The courier of the magic academy, little Y, has earned the title of "Best Magic Courier". But the dean dislikes him, so he gives him a very difficult task. The dean gives him the coordinates (xi,yi)(x_i, y_i) of nn magic nodes; he must deliver the magic packages to these nodes. He will make the deliveries in the following way:

  • The magic package is crafted at point (Ax,Ay)(Ax, Ay), and little Y starts delivering from this point.
  • He may move from (x,y)(x, y) to any one of the three points (x+1,y)(x+1, y), (x,y+1)(x, y+1), or (x,y−1)(x, y-1).
  • After delivering all the packages, he must return to the academy, i.e. return to (Bx,By)(Bx, By).

Each move takes exactly one second, and delivering a package takes no time (00 seconds). The dean wants the delivery to be as fast as possible. You need to compute the minimum time to finish delivering all the magic packages. It is guaranteed that all nodes can be visited.

Input Format

Each test contains several test cases. The first line contains an integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases. This is followed by the description of each test case.

The first line of each test case contains five integers nn, AxAx, AyAy, BxBx, ByBy (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5, 1≤Ax,Ay,Bx,By≤1091 \le Ax, Ay, Bx, By \le 10^9), the number of magic nodes to deliver and the coordinates of the start and end points.

The second line contains nn integers x1,x2,…,xnx_1, x_2, \dots, x_n (Ax<xi<BxAx < x_i < Bx).

The third line contains nn integers y1,y2,…,yny_1, y_2, \dots, y_n (1≤yi≤1091 \le y_i \le 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

Output Format

For each test case, output one integer on its own line: the minimum time to finish delivering all the magic packages.

Sample Input #1

4
1 2 3 5 2
4
4
3 1 3 5 2
3 4 3
5 4 1
6 1 2 7 3
5 2 3 5 5 3
6 4 3 1 4 1
5 6 9 8 6
7 7 7 7 7
3 1 8 8 3

Sample Output #1

6
13
19
15

Explanation / Hint

Take the second test case as an example:

  • Moving from (Ax,Ay)(Ax, Ay) to (x3,y3)(x_3, y_3) takes 44 seconds.
  • Moving from (x3,y3)(x_3, y_3) to (x1,y1)(x_1, y_1) takes 44 seconds.
  • Moving from (x1,y1)(x_1, y_1) to (x2,y2)(x_2, y_2) takes 22 seconds.
  • Moving from (x2,y2)(x_2, y_2) to (Bx,By)(Bx, By) takes 33 seconds.

The total time is 4+4+2+3=134+4+2+3=13 seconds. It can be proven that no faster delivery is possible.