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]$$$:
There are a total of $$$m$$$ groups of queries in this problem. For each query, values of $$$x$$$ , $$$y$$$ , $$$A$$$ and $$$B$$$ are given.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 two single integers $$$n,m$$$ $$$(1\leq n,m\leq 10^5)$$$.
The second line gives $$$n$$$ positive integers, representing the permutation $$$p$$$.
The third line gives $$$n$$$ positive integers, representing the permutation $$$q$$$.
The next $$$m$$$ lines each contain four positive integers $$$A$$$, $$$B$$$, $$$x$$$, and $$$y$$$ $$$(1 \leq A,B \leq n^2,1 \leq x \leq y \leq 10^9)$$$.
It is guaranteed that the sum of $$$n$$$ and $$$m$$$ over all test cases does not exceed $$$10^5$$$.
For each set of data, output $$$m$$$ lines. The $$$i$$$-th line contains an integer representing the answer to the $$$i$$$-th query.
15 61 3 2 5 43 2 1 4 54 9 1 45 9 1 35 16 3 316 5 3 45 5 2 39 9 10 11
4 6 -1 -1 8 42
| Name |
|---|


