Once again, we have a lot of requests from coders for a challenging problem on geometry. Geometry expert Nitin is thinking about a problem with parabolas, icosahedrons, crescents and trapezoids, but for now, to encourage beginners, he chooses to work with circles and rectangles.
You are given two sequences $A_1, A_2, \ldots, A_N$ and $B_1, B_2, \ldots, B_N$. You should choose a permutation $P_1, P_2, \ldots, P_N$ of the integers $1$ through $N$ and construct $N$ rectangles with dimensions $A_1 \times B_{P_1}, A_2 \times B_{P_2}, \ldots, A_N \times B_{P_N}$. Then, for each of these rectangles, you should construct an inscribed circle, i.e. a circle with the maximum possible area that is completely contained in that rectangle.
Let $S$ be the sum of diameters of these $N$ circles. Your task is to find the maximum value of $S$.

-----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 maximum value of $S$. It is guaranteed that this value is always an integer.

-----Constraints-----
- $1 \le T \le 50$
- $1 \le N \le 10^4$
- $1 \le A_i, B_i \le 10^9$ for each valid $i$

-----Subtasks-----
Subtask #1 (20 points):
- $A_1 = A_2 = \ldots = A_N$
- $B_1 = B_2 = \ldots = B_N$
Subtask #2 (80 points): original constraints

-----Example Input-----
2
4
8 8 10 12
15 20 3 5
3
20 20 20
10 10 10

-----Example Output-----
30
30

-----Explanation-----
Example case 1: Four rectangles with dimensions $8 \times 3$, $8 \times 5$, $10 \times 20$ and $12 \times 15$ lead to an optimal answer.

Starter code:

Solutions:
for _ in range(int(input())):
 n=int(input())
 a=list(map(int,input().split()))
 b=list(map(int,input().split()))
 a.sort()
 b.sort()
 s=0
 for i in range(n):
  s+=min(a[i],b[i])
 print(s)

for t in range(int(input())):
 n = int(input())
 A = sorted(list(map(int, input().split())))
 B = sorted(list(map(int, input().split())))
 s = 0
 for i in range(n):
  s = s+min(A[i],B[i])
 print(s)


t=int(input())
while t:
 n=int(input())
 a=[int (o) for o in input().split()]
 b=[int (o) for o in input().split()]
 a.sort()
 b.sort()
 s=0
 if a[0]==a[n-1] and b[0]==b[n-1]:
  print(n*min(a[0],b[0]))
 else:
  for i in range(n):
   s+=min(a[i],b[i])
  print(s)
 t-=1


t=int(input())
while t:
 n=int(input())
 a=[int (o) for o in input().split()]
 b=[int (o) for o in input().split()]
 a.sort()
 b.sort()
 if a[0]==a[n-1] and b[0]==b[n-1]:
  print(n*min(a[0],b[0]))
 t-=1


import itertools
t=int(input())
for i in range(t):
 n=int(input())
 a=list(map(int,input().split()))
 a.sort()
 b=list(map(int,input().split()))
 b.sort()
 s=0
 for (f,g) in zip(a,b):
  s+=min(f,g)
 print(s)

# cook your dish here
t=int(input())
for i in range(t):
 c=0
 n=int(input())
 a=[int(j) for j in input().split()]
 b=[int(j) for j in input().split()]
 a.sort()
 b.sort()
 for j in range(len(a)):
  if(a[j]<b[j]):
   c+=a[j]
  else:
   c+=b[j]
 print(c)


for _ in range(int(input())):
 n=int(input())
 a=list(map(int,input().split()))
 b=list(map(int,input().split()))
 a.sort()
 b.sort()
 s=0
 for i,j in zip(a,b):
  s+=min(i,j)
 print(s)

t = int(input())
for i in range(t):
 n = int(input())
 sum = 0
 a = sorted((list(map(int,input().split()))))
 b = sorted((list(map(int,input().split()))))
 for j in range(n):
  if(a[j]<b[j]):
   sum += a[j];
  else:
   sum += b[j];
 print(sum)




for t in range(int(input())):
 n=int(input())
 length=[int(i)for i in input().split()]
 width=[int(i)for i in input().split()]
 length.sort()
 width.sort()
 sum=0
 for j in range(n):
  sum=sum+min(length[j],width[j])
 print(sum) 

for t in range(int(input())):
 n=int(input())
 length=[int(i)for i in input().split()]
 width=[int(i)for i in input().split()]
 length.sort()
 width.sort()
 sum=0
 for j in range(n):
  sum=sum+min(length[j],width[j])
 print(sum,"\n") 

for t in range(int(input())):
 n=int(input())
 length=[int(i)for i in input().split()]
 width=[int(i)for i in input().split()]
 length.sort()
 width.sort()
 sum=0
 for j in range(n):
  sum=sum+min(length[j],width[j])
 print(sum) 

for t in range(int(input())):
 n=int(input())
 length=[int(i)for i in input().split()]
 width=[int(i)for i in input().split()]
 length.sort()
 width.sort()
 sum=0
 for j in range(n):
  sum=sum+min(length[j],width[j])
 print(sum) 

for t in range(int(input())):
 n=int(input())
 length=[int(i)for i in input().split()]
 width=[int(i)for i in input().split()]
 length.sort()
 width.sort()
 sum=0
 for j in range(n):
  sum+=min(length[j],width[j])
 print(sum) 

for t in range(int(input())):
 n=int(input())
 length=[int(i)for i in input().split()]
 width=[int(i)for i in input().split()]
 length.sort()
 width.sort()
 sum=0
 for j in range(n):
  sum+=min(length[j],width[j])
 print(sum) 


for t in range(int(input())):
 n=int(input())
 length=[int(i)for i in input().split()]
 width=[int(i)for i in input().split()]
 length.sort()
 width.sort()
 s=0
 for j in range(n):
  s+=min(length[j],width[j])
 print(s) 


for t in range(int(input())):
 n=int(input())
 l=[int(i)for i in input().split()]
 m=[int(i)for i in input().split()]
 l.sort()
 m.sort()
 s=0
 for j in range(n):
  s+=min(l[j],m[j])
 print(s) 


for t in range(int(input())):
 n=int(input())
 l=[int(k)for k in input().split()]
 m=[int(k)for k in input().split()]
 l.sort()
 m.sort()
 s=0
 for j in range(n):
  s+=min(l[j],m[j])
 print(s) 


for i in range(int(input())):
 n=int(input())
 l=[int(k)for k in input().split()]
 m=[int(k)for k in input().split()]
 l.sort()
 m.sort()
 s=0
 for j in range(n):
  s+=min(l[j],m[j])
 print(s) 


for i in range(int(input())):
 n=int(input())
 l=[int(k)for k in input().split()]
 m=[int(k)for k in input().split()]
 l.sort()
 m.sort()
 s=0
 for j in range(n):
  s+=min(l[j],m[j])
 print(s) 
 


for i in range(int(input())):
 n=int(input())
 l=[int(k)for k in input().split()]
 m=[int(k)for k in input().split()]
 l.sort()
 m.sort()
 s=0
 for j in range(n):
  s+=min(l[j],m[j])
 print(s) 


# MOD = 1000000007
for _ in range(int(input())):
 # n,k = map(int,input().split())
 n = int(input())
 a = sorted(map(int,input().split()))
 b = sorted(map(int,input().split()))
 print(sum(map(min,list(zip(a,b)))))


# cook your dish here
t = int(input())

for _ in range(t):
 n = int(input())
 
 a = [int(x) for x in input().split()]
 b = [int(x) for x in input().split()]
 
 a.sort()
 b.sort()
 
 ans = 0
 for i in range(n):
  ans += min(a[i],b[i])
  
 print(ans)

t = int(input())

for _ in range(t):
 n = int(input())
 
 a = [int(x) for x in input().split()]
 b = [int(x) for x in input().split()]
 
 a.sort()
 b.sort()
 
 ans = 0
 for i in range(n):
  ans += min(a[i], b[i])
 
 print(ans)

# cook your dish here
for t in range(int(input())):
 n=int(input())
 a=[int(i) for i in input().split()]
 a.sort()
 b=[int(i) for i in input().split()]
 b.sort()
 s=0
 for i in range(n):
  s+=min(a[i],b[i])
 print(s)

# cook your dish here
t = int(input())
for _ in range(t):
 n = int(input())
 a = list(map(int, input().split()))
 b = list(map(int, input().split()))
 a.sort()
 b.sort()
 tot = 0
 for i in range(n):
  tot = tot + min(a[i],b[i])
 print(tot)