Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

greedy

implementation

*1100

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Increase/Decrease/Copy

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given two integer arrays: array $$$a$$$ of length $$$n$$$ and array $$$b$$$ of length $$$n+1$$$.

You can perform the following operations any number of times in any order:

- choose any element of the array $$$a$$$ and increase it by $$$1$$$;
- choose any element of the array $$$a$$$ and decrease it by $$$1$$$;
- choose any element of the array $$$a$$$, copy it and append the copy to the end of the array $$$a$$$.

Your task is to calculate the minimum number of aforementioned operations (possibly zero) required to transform the array $$$a$$$ into the array $$$b$$$. It can be shown that under the constraints of the problem, it is always possible.

Input

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

Each test case consists of three lines:

- the first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$);
- the second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$);
- the third line contains $$$n + 1$$$ integers $$$b_1, b_2, \dots, b_{n + 1}$$$ ($$$1 \le b_i \le 10^9$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Output

For each test case, print a single integer — the minimum number of operations (possibly zero) required to transform the array $$$a$$$ into the array $$$b$$$.

Example

Input

3121 323 33 3 344 2 1 22 1 5 2 3

Output

3 1 8

Note

In the first example, you can transform $$$a$$$ into $$$b$$$ as follows: $$$[2] \rightarrow [2, 2] \rightarrow [1, 2] \rightarrow [1, 3]$$$.

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/18/2024 11:47:27 (i1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|