You have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i oranges.

During one move, you can choose some gift 1 ≤ i ≤ n and do one of the following operations:

  * eat exactly one candy from this gift (decrease a_i by one); 
  * eat exactly one orange from this gift (decrease b_i by one); 
  * eat exactly one candy and exactly one orange from this gift (decrease both a_i and b_i by one). 



Of course, you can not eat a candy or orange if it's not present in the gift (so neither a_i nor b_i can become less than zero).

As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: a_1 = a_2 = ... = a_n and b_1 = b_2 = ... = b_n (and a_i equals b_i is not necessary).

Your task is to find the minimum number of moves required to equalize all the given gifts.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.

The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of gifts. The second line of the test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the number of candies in the i-th gift. The third line of the test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9), where b_i is the number of oranges in the i-th gift.

Output

For each test case, print one integer: the minimum number of moves required to equalize all the given gifts.

Example

Input


5
3
3 5 6
3 2 3
5
1 2 3 4 5
5 4 3 2 1
3
1 1 1
2 2 2
6
1 1000000000 1000000000 1000000000 1000000000 1000000000
1 1 1 1 1 1
3
10 12 8
7 5 4


Output


6
16
0
4999999995
7

Note

In the first test case of the example, we can perform the following sequence of moves:

  * choose the first gift and eat one orange from it, so a = [3, 5, 6] and b = [2, 2, 3]; 
  * choose the second gift and eat one candy from it, so a = [3, 4, 6] and b = [2, 2, 3]; 
  * choose the second gift and eat one candy from it, so a = [3, 3, 6] and b = [2, 2, 3]; 
  * choose the third gift and eat one candy and one orange from it, so a = [3, 3, 5] and b = [2, 2, 2]; 
  * choose the third gift and eat one candy from it, so a = [3, 3, 4] and b = [2, 2, 2]; 
  * choose the third gift and eat one candy from it, so a = [3, 3, 3] and b = [2, 2, 2]. 
# Codeforces round 655

'''test=int(input())
for i in range(test):
    n=int(input())
    arr=[1 for i in range(n)]
    print(*arr)'''

'''test=int(input())
for i in range(test):
    n=int(input())
    i=2
    arr=[]
    while i**2<=n:
        if n%i==0:
            arr.append(i)
            arr.append(n/i)
        i+=1
    if arr:
        k=max(arr)
        print(int(k),int(n-k))
    else:
        print(1,n-1)'''

'''test=int(input())
for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    t=arr.copy()
    t.sort()
    j=n
    for i in range(n-1,-1,-1):
        if arr[i]==t[i]:
            j-=1
        else:
            break
    arr=arr[:j]
    if not arr:
        print(0)
    else:
        dp=[0 for j in range(len(arr))]
        for i in range(len(arr)):
            if arr[i]==t[i]:
                dp[i]=1
            else:
                dp[i]=0
        cnt=0
        recent=-1
        for i in range(1,len(arr)):
            if dp[i]==1 and dp[i-1]==0:
                cnt+=1
        print(dp)
        if not cnt:
            print(1)
        else:
            cnt+=1 if dp[-1]==0 else 0
            print(cnt)'''


#codeforces educational round
'''string=input()
patt=input()
from collections import defaultdict
ans=float("inf")
cnt=defaultdict(int)
for i in patt:
    cnt[i]+=1
l=0
cnt_2=defaultdict(int)
for i in range(len(string)):
    if string[i] in patt:
        cnt_2[string[i]]+=1
    print(cnt_2)
    flag=0
    while all(cnt[k]==cnt_2[k] for k in cnt.keys()):
        if string[l] in patt:
            cnt_2[string[l]]-=1
        l+=1
        flag=1
    if flag:
        l-=1
        cnt_2[string[l]]+=1
        flag=0
        print(l)
        ans=min(ans,i-l+1)
        print(i-l+1)

print(ans)'''
    
'''n,m=[int(i) for i in input().split()]
if m==n:
    s=""
    for i in range(m):
        s+="10"
    print(s)
elif m>n:
    if m>2*(n+1):
        print(-1)
    else:
        s=""
        for i in range(m-n-1):
            s+="110"
        for j in range(2*(n+1)-m):
            s+="10"
        print(s[:m+n])
else:
    if n>m+1:
        print(-1)
    else:
        s=""
        for j in range(m):
            s+="01"
        s+="0"
        print(s)'''

'''n=int(input())
dates=[]
for i in range(n):
    a,b=[int(j) for j in input().split()]
    dates.append([a,b])
dates.sort(key=lambda x: x[0])
ans=dates[0][1]
from collections import defaultdict
cnt=defaultdict(int)
for i in range(n):
    if cnt[dates[i][0]]<dates[i][1]:
        cnt[dates[i][0]]=dates[i][1]
        
#print(cnt)
for i in range(1,n):
    if cnt[dates[i][0]]>=ans:
        ans=cnt[dates[i][0]]
    else:
        ans=dates[i][0]
print(ans)
print (cnt)'''
    

'''n=int(input())
arr=[int(i) for i in input().split()]
from collections import defaultdict
cnt=defaultdict(int)
for i in arr:
    cnt[i]+=1
k=max(arr)
dp=[0 for i in range(k+1)]
dp[0]=0
dp[1]=cnt[1]
for i in range(2,k+1):
    dp[i]=max(dp[i-1],dp[i-2] + cnt[i]*i)
    #print(dp[i])
print(dp[-1])'''

#Codeforces round 656 DIV-3
'''test=int(input())
for i in range(test):
    x,y,z=[int(i) for i in input().split()]
    if x==y==z:
        print("YES")
        print(x,y,z)
    else:
        if z==x and y<x:
            print("YES")
            print(y,x,max(1,y-1))
        elif y==z and x<y:
            print("YES")
            print(x,max(1,x-1),y)
        elif x==y and z<y:
            print("YES")
            print(x,z,max(1,z-1))
        else:
            print("NO")
'''

'''def check(num,curr):
    if not num:
        return True
    if len(num)==1:
        if num[0]>=curr:
            return True
        return False
    if num[0]<=num[-1] and num[0]>=curr:
        return True and check(num[1:],min(num[0],num[-1]))
    elif num[0]>=num[-1] and num[-1]>=curr:
        return True and check(num[:-1],min(num[0],num[-1]))
    return False'''
'''test=int(input())
for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    j=n-1
    flag=1
    while j>0:
        if arr[j]>arr[j-1]:
            flag=0
            break
        j-=1
    while j>0:
        if arr[j]<arr[j-1]:
            flag=0
            break
        j-=1
    if not flag:
        ans=j
    else:
        ans=0
    print(ans)'''


    






'''def min_(l,r,ch):
    cnt=0
    for i in range(l,r+1):
        if s[i]!=ch:
            cnt+=1
    return cnt 
def check(l,r,t):
    if l==r:
        if s==chr(ord("a")+t):
            return 0
        return 1
    mid=(l+r)//2
    
    return min(check(mid+1,r,t+1)+min_(l,mid,chr(ord("a")+t)),
           check(l,mid,t+1)+min_(mid+1,r,chr(ord("a")+t)))
        
test=int(input())
for i in range(test):
    n=int(input())
    s=str(input())
    print(check(0,n-1,0))'''
            

        
'''test=int(input())
for i in range(test):
    n=int(input())
    s=input()
    cnt=0
    t="abacaba"
    for i in range(n-6):
        flag=1
        for j in range(7):
            if s[i+j]!=t[j]:
                flag=0
        if flag:
            cnt+=1
    if cnt==1:
        print("YES")
        for j in range(n):
            if s[j]=="?":
                s=s[:j]+"z"+s[j+1:]
        print(s)
    elif cnt==0:
        opt=-1
        for i in range(n-6):
            flag=1
            for j in range(7):
                if s[i+j]==t[j] or s[i+j]=="?":
                    continue
                else:
                    flag=0
                    break

            if flag:
                opt=i
                break
        if opt!=-1:
            for i in range(7):
                if s[opt+i]=="?":
                    s=s[:opt+i]+t[i]+s[opt+i+1:]
                
            for i in range(n):
                if s[i]=="?":
                    s=s[:i]+"z"+s[i+1:]
            cnt_=0
            for i in range(n-6):
                flag=1
                for j in range(7):
                    if s[i+j]!=t[j]:
                        flag=0
                if flag:
                    cnt_+=1
            if cnt_==1:
            
                print("Yes")
                print(s)
            else:
                print("NO")
        else:
            print("NO")
    else:
        print("NO")'''


            



'''test=int(input())
for i in range(test):
    initial=[int(i) for i in input().split()]
    n=initial[0]
    m=initial[1]
    a=[]
    b=[]
    for j in range(m):
        k,p=[int(i) for i in input().split()]
        a.append(k)
        b.append([k,p])
    a.sort()
    pre=[0 for i in range(m)]
    pre[-1]=a[-1]
    for i in range(m-2,-1,-1):
        pre[i]=a[i]+pre[i+1]
    cnt=0
    for i in range(m):
        l=0
        r=m-1
        ans=m
        while l<=r:
            mid=l+(r-l)//2
            if a[mid]>= b[i][1]:
                ans=mid
                r=mid-1
            else:
                l=mid+1
        if ans!=m:
            t=n-(m-ans)
            cnt=max(cnt,pre[ans]+(t)*b[i][1])
        else:
            cnt=max(cnt,b[i][0]+(n-1)*(b[i][1]))
        print(cnt)
    print(cnt)'''

'''test=int(input())
for i in range(test):
    n,m=[int(i) for i in input().split()]
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]
    ele_1=set()
    for i in a:
        ele_1.add(i)
    ans=-1
    for j in b:
        if j in ele_1:
            ans=j
            break
    if ans!=-1:
        print("YES")
        print(1,ans,sep=" ")
       
    else:
        print("NO")
'''
'''test=int(input())
for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    win="First"
    i=0
    cnt=0
    for i in range(n-1):
        if arr[i]==1:
            cnt+=1
        else:break
    if cnt%2:
        print("Second")
    else:
        print("First")'''

'''test=int(input())
for i in range(test):
    n=int(input())
    a=[i for i in input()]
    b=[i for i in input()]
    ans=[]
    if a==b:
        print(0)
    else:
        for i in range(n-1,-1,-1):
            if a[i]!=b[i]:
                if a[i]!=a[0]:
                    ans.append(1)
                    a[0]=a[i]
                for i in range(i+1):
                    if a[i]=="0":
                        a[i]='1'
                    else:
                        a[i]="0"
                a[:i+1]=a[:i+1][::-1]
                
                ans.append(i+1)
        print(len(ans),*ans,sep=" ")
'''



#Codeforces round div-2 659

'''test=int(input())
def update(k):
    if k<25:
        k+=1
    else:
        k=0
    return k
for i in range(test):
    n=int(input())
    arr=[int(i) for i in input().split()]
    ans=[]
    t=max(max(arr),1)
    ans=['a'*t]
    for i in range(len(arr)):
        if arr[i]==t:
            ans.append(ans[-1])
        elif arr[i]==0:
            if ans[-1][0]=="a":
                ans.append("b"*t)
            else:
                ans.append("a"*t)
        else:
            st=ans[-1][:arr[i]]
            if ans[-1][arr[i]:][0]=="b":
                st+="a"*(t-arr[i])
                ans.append(st)
            else:
                st+="b"*(t-arr[i])
                ans.append(st)
    for i in ans:
        print(i)
'''



'''n,w=[int(i) for i in input().split()]
dp=[0 for i in range(w+1)]
for i in range(n):
    weight,val=[int(i) for i in input().split()]

    for j in range(w-weight,-1,-1):
        dp[j+weight]=max(dp[j+weight],dp[j]+val)

ans=0
print(max(dp))'''

'''n,w=[int(i) for i in input().split()]
wi=[]
val=[]
for i in range(n):
    a,b=[int(i) for i in input().split()]
    wi.append(a)
    val.append(b)
tot=sum(val)
dp=[float("inf") for i in range(tot+1)]
dp[0]=0
for i in range(n):
    for j in range(tot-val[i],-1,-1):
        dp[j+val[i]]=min(dp[j+val[i]],dp[j]+wi[i])
ans=0
for i in range(len(dp)):
    if dp[i]<=w:
        ans=max(ans,i)
print(ans)'''
'''t=input()
s=input()

dp=[[0]*(len(s)+1)]*(len(t)+1)
m=len(t)
n=len(s)
length=0
row=0
col=0
for i in range(m+1):
    for j in range(n+1):
        if i==0 or j==0:
            dp[i][j]=0
        elif t[i-1]==s[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

max_=dp[-1][-1]
a=""
i=m
j=n
while i>0 and j>0:
    if t[i-1]==s[j-1]:
        a+=t[i-1]
        i-=1
        j-=1
    elif dp[i-1][j]>dp[i][j-1]:
        i-=1
    else:
        j-=1
print(a[::-1],dp[-1][-1])''' 


'''n,m=[int(i) for i in input().split()]
from collections import defaultdict
edges=[]
for i in range(m):
    edges.append([int(i) for i in input().split()])
dp=[0 for i in range(n+1)]
for i'''
'''n=int(input())
dates=[]
for i in range(n):
    a,b=[int(i) for i in input().split()]
    dates.append([a,b])
dates=sorted(sorted(dates,key=lambda x:x[1]),key=lambda x:x[0])
ans=dates[0][1]
assigned=[float("inf")]*(n)
assigned[0]=ans
for i in range(1,n):
    if dates[i][0]<assigned[i] and dates[i][0]>=ans:
        assigned[i]=dates[i][0]
    if dates[i][1]<assigned[i] and dates[i][1]>=ans:
        assigned[i]=dates[i][1]
    ans=assigned[i]
print(assigned[-1])'''

'''test=int(input())
for i in range(test):
    x,y=[int(i) for i in input().split()]
    if 2*x>y:
        print(-1,-1)
    elif y%x==0:
        print(x,y)
    else:
        print(x,2*x)'''
    
'''test=int(input())
for i in range(test):
    n,k,z=[int(i) for i in input().split()]
    arr=[int(i) for i in input().split()]
    if z==0:
        print(sum(arr[:min(n,k+1)]))
    else:
        pre=[arr[0]]*(n)
        for i in range(1,n):
            pre[i]=pre[i-1]+arr[i]
        dip=[arr[0]]*(n)
        for i in range(1,n):
            dip[i]=max(arr[i]+arr[i-1],dip[i-1])
        ans=0
        for i in range(0,z+1):
            if k-i*2>0:
                ans=max(ans,pre[k-i*2]+dip[k-i*2]*i)
                print(ans)
        print(ans,pre,dip)'''

'''t=int(input())
from collections import defaultdict
for i in range(test):
    s=int(input())
    cnt=defaultdict(int)
    for i in s:
        cnt[s]+=1
    a=sorted(cnt.items(),key=lambda x:x[1],reverse=True)
    new=""
    for i in s:
        if i in [a[0][0],a[1][0]]:
            new+=i'''
    
'''s=input()
n=len(s)
dp=[0]*(n)
for i in range(n-1):
    if s[i]==s[i+1]:
        dp[i]=1+dp[i-1] if i>0 else 1
    else:
        dp[i]=dp[i-1] if i>0 else 0
dp[-1]=dp[-2]
m=int(input())
for i in range(m):
    l,r=[int(i) for i in input().split()]
    left=dp[l-2] if l>1 else 0
    right=dp[r-2]
    print(right-left)'''


#Codeforces round 660 DIV-2

'''test=int(input())
for i in range(test):
    n=int(input())
    prime=[6,10,14,15]
    if n<=30:
        print("NO")
    elif n in [36,44,40]:
        print("YES")
        print(15,10,6,n-31)
    
    else:
        print("YES")
        print(6,10,14,n-30)'''

'''n=int(input())
def f(x):
    return [int(i) for i in str(x)]
a=f(n)
print(a)
dp=[[0]*(10)]*(len(a))
dp[-1][a[-1]]=1

for i in range(len(a)-2,-1,-1):
    dp[i][a[i]]+=1
    for j in range(10):
        dp[i][j]=dp[i+1][j]
    
    print(dp[i])
print(dp)


if 0 in a:
    print("YES")
    print(0)
elif 8 in a:
    print("YES")
    print(8)
else:
    ok=0
    for i in range(len(a)-1):
        flag=0
        num=0
        for j in range(i+1,len(a)):
            if a[i]!=0:
                k=int(str(a[i])+str(a[j]))
                if k%8==0:
                    flag=1
                    num=k
                    break
                else:
                    t=k*10
                    required=8-t%8
                    if j<len(a)-1 and dp[j+1][required]>0:
                        flag=1 
                        num=t+required
                        break
        if flag:
            print("YES")
            print(num)
            ok=1
            break

    if not ok:
        print("NO")'''
'''s=input()
k=int(input())
dp=[0]*(len(s))
dp[0]=int(s[0])
for i in range(1,len(s)):
    for j in range(1,i+1):
        if int(s[i-j+1:i+1])<=k:
            dp[i]=max(dp[i],dp[i-j]+int(s[i-j+1:i+1]))

print(dp)'''


# virtual contest of Codeforces round 661 DIV-3

'''test=int(input())
from collections import defaultdict
for i in range(test):

    n=int(input())
    arr=[int(i) for i in input().split()]
    if n==1:
        print("YES")
    else:
        max_=max(arr)
        min_=min(arr)
        cnt=defaultdict(int)
        for i in range(n):
            cnt[arr[i]]=1
        if all(cnt[j]==1 for j in range(min_,max_+1)):
            print("YES")
        else:
            print("NO")'''


for i in range(int(input())):
    n=int(input())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]
    k1=min(a)
    k2=min(b)
    ans=0
    for i in range(n):
        ans+=max(a[i]-k1,b[i]-k2)
    print(ans)






