Chefina has two sequences $A_1, A_2, \ldots, A_N$ and $B_1, B_2, \ldots, B_N$. She views two sequences with length $N$ as identical if, after they are sorted in non-decreasing order, the $i$-th element of one sequence is equal to the $i$-th element of the other sequence for each $i$ ($1 \le i \le N$).
To impress Chefina, Chef wants to make the sequences identical. He may perform the following operation zero or more times: choose two integers $i$ and $j$ $(1 \le i,j \le N)$ and swap $A_i$ with $B_j$. The cost of each such operation is $\mathrm{min}(A_i, B_j)$.
You have to find the minimum total cost with which Chef can make the two sequences identical.
-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $A_1, A_2, \ldots, A_N$.
- The third line contains $N$ space-separated integers $B_1, B_2, \ldots, B_N$.
-----Output-----
For each test case, print a single line containing one integer ― the minimum cost, or $-1$ if no valid sequence of operations exists.
-----Constraints-----
- $1 \le T \le 2,000$
- $1 \le N \le 2 \cdot 10^5$
- $1 \le A_i, B_i \le 10^9$ for each valid $i$
- the sum of $N$ over all test cases does not exceed $2 \cdot 10^6$
-----Subtasks-----
Subtask #1 (15 points):
- $T \le 20$
- $N \le 20$
Subtask #2 (85 points): original constraints
-----Example Input-----
3
1
1
2
2
1 2
2 1
2
1 1
2 2
-----Example Output-----
-1
0
1
-----Explanation-----
Example case 1: There is no way to make the sequences identical, so the answer is $-1$.
Example case 2: The sequence are identical initially, so the answer is $0$.
Example case 3: We can swap $A_1$ with $B_2$, which makes the two sequences identical, so the answer is $1$.
for _ in range(int(input())):
 n = int(input())
 a = list(map(int, input().split()))
 b = list(map(int, input().split()))
 minimum = min(min(a), min(b))
 s = set()
 ad = {}
 bd = {}
 for i in a:
  if i in s:
   s.remove(i)
  else:
   s.add(i)
  ad[i] = ad.setdefault(i, 0) + 1
  bd[i] = bd.setdefault(i, 0) - 1
 for i in b:
  if i in s:
   s.remove(i)
  else:
   s.add(i)
  bd[i] = bd.setdefault(i, 0) + 1
  ad[i] = ad.setdefault(i, 0) - 1
 if len(s) > 0:
  print("-1")
  continue
 a = []
 b = []
 for i in ad.keys():
  if ad[i] > 0:
   a.extend([i] * (ad[i] // 2))
 for i in bd.keys():
  if bd[i] > 0:
   b.extend([i] * (bd[i] // 2))
 cost = 0
 for i in range(len(a)):
  cost += min(min(a[i], b[len(a) - 1 - i]), 2 * minimum)
 print(cost)
for _ in range(int(input())):
 n = int(input())
 a = list(map(int, input().split()))
 b = list(map(int, input().split()))
 minimum = min(min(a), min(b))
 s = set()
 ad = {}
 bd = {}
 for i in a:
  if i in s:
   s.remove(i)
  else:
   s.add(i)
  ad[i] = ad.setdefault(i, 0) + 1
  bd[i] = bd.setdefault(i, 0) - 1
 for i in b:
  if i in s:
   s.remove(i)
  else:
   s.add(i)
  bd[i] = bd.setdefault(i, 0) + 1
  ad[i] = ad.setdefault(i, 0) - 1
 if len(s) > 0:
  print("-1")
  continue
 a = []
 b = []
 for i in ad.keys():
  if ad[i] > 0:
   a.extend([i] * (ad[i] // 2))
 for i in bd.keys():
  if bd[i] > 0:
   b.extend([i] * (bd[i] // 2))
 cost = 0
 for i in range(len(a)):
  cost += min(min(a[i], b[len(a) - 1 - i]), 2 * minimum)
 print(cost)