Give two permutations $$$p$$$ and $$$q$$$ of length $$$n$$$. It is guaranteed that $$$n$$$ is an odd number. You must perform exactly one of the following operations for each position $$$i \in [1,n]$$$:
Please find the minimum cost required to make the median of array $$$p$$$ equal to $$$A$$$ and the median of array $$$q$$$ equal to $$$B$$$. If it's impossible, output $$$-1$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \leq t \leq 10^4)$$$ . The description of the test cases follows.
The first line of each test case contains three single integers $$$n,A,B$$$ $$$(1 \leq n \leq 10^5,1 \leq A,B \leq n^2)$$$.
The second line gives $$$n$$$ positive integers, representing the permutation $$$p$$$.
The third line gives $$$n$$$ positive integers, representing the permutation $$$q$$$.
The fourth line gives $$$n$$$ positive integers, representing the array $$$x$$$ .
The fifth line gives $$$n$$$ positive integers, representing the array $$$y$$$ $$$(1 \leq x_i \leq y_i \leq10^4)$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.
For each test case, output $$$-1$$$ if it is impossible.
Otherwise, output the minimum cost.
All outputs must be printed on separate lines.
37 6 77 3 5 6 2 4 11 6 3 4 2 7 55 1 1 4 4 1 16 4 6 6 6 1 19 5 51 2 3 4 5 6 7 8 99 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 92 3 4 5 6 7 8 9 93 2 31 2 32 3 110000 1 110000 1 1
7 0 10000
| Name |
|---|


