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]. 
//package com.company;

//-------------------------------------------># DEVIL CODER # -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------





import java.math.*;
import javax.swing.*;
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
//-------------------Main function ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public class Main {
    //---------------Reader class for Fast Input------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;


        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }


        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        // ----------------------Down-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        // Down---------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        // Down---------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        // Down---------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        // Down---------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>---------------------------------------------------------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        // Down---------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        // Down---------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }

    // ---------------->>>>>>>>>seieve of erathoshenes ------------------------------------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    static ArrayList<Integer> sieveOfEratosthenes(int n) {
        boolean prime[] = new boolean[n + 1];
        for (int i = 0; i < n; i++)
            prime[i] = true;

        for (int p = 2; p * p <= n; p++) {
            // If prime[p] is not changed, then it is a prime
            if (prime[p] == true) {
                // Update all multiples of p
                for (int i = p * p; i <= n; i += p)
                    prime[i] = false;
            }
        }
        ArrayList<Integer> l = new ArrayList<>();
        for (int i = 2; i <= n; i++) {
            if (prime[i] == true)
                l.add(i);
        }
        return l;
    }

    // ---------------------------------GCD>>>>>>>>>>>>>>>>>>>>>>>>>>>>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    static ArrayList<Integer> factor(int n) {
        ArrayList<Integer> l = new ArrayList<>();

        for (int i = n; i <= 1e5; i++) {
            if (i % n == 0)
                l.add(n);
        }
        return l;
    }


    // ------------------------------------------------------------------------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//map code
      /*
                                                 if (h.containsKey(A[i]))
                                                   h.put(A[i], h.get(A[i]) + 1);
                                               else
                                                   h.put(A[i], 1);

                                         ArrayList<Integer> l = new ArrayList<>();
                                          for(Map.Entry mp:h.entrySet())
                                            {
                                                if((int)mp.getValue()>1)
                                                {
                                                    sum+=(int)mp.getValue();
                                                }
                                                else
                                                {
                                                  l.add((int)mp.getKey());
                                                }
                                            }
                                            Collections.sort(l);
                                            for(int i=0;i<l.size();i++)
                                            {
                                                int x=l.get(i);
                                                if(sum>=x)
                                                    sum++;
                                            }*/


    //---------------->>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// ---------------->>>>>>>>>Coding begins ------------------------------------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    public static int maxSum(int arr[], int n, int k) {
        // k must be greater
        if (n < k) {
            System.out.println("Invalid");
            return -1;
        }

        // Compute sum of first window of size k
        int res = 0;
        for (int i = 0; i < k; i++)
            res += arr[i];

        // Compute sums of remaining windows by
        // removing first element of previous
        // window and adding last element of
        // current window.
        int curr_sum = res;
        for (int i = k; i < n; i++) {
            curr_sum += arr[i] - arr[i - k];
            res = Math.max(res, curr_sum);
        }

        return res;
    }

    ///------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    static class customer implements Comparable<customer> {
        int start;
        int end;
        int pre;

        customer(int start, int end, int pre) {
            this.start = start;
            this.end = end;
            this.pre = pre;
        }

        public int compareTo(customer a) {
            return end - a.end;
        }

    }
    //-=============********************////////////////----------------///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    //---------------->>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//----<<<<<<<<<------------>>>>>>>>>>>>>### $$$solve ### devil_coder$$$#######<<<<<<<------------------>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


//----------------Main function----------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-------------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    public static void main(String[] args) throws java.lang.Exception
    {

        Reader sc = new Reader();
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        //int t = Integer.parseInt(br.readLine());

        StringBuffer sb = new StringBuffer();

        //int max=10000000;
        int t = sc.nextInt();
         while (t-- > 0)
          {
        // int n=Integer.parseInt(br.readLine());
        int n=sc.nextInt();

        ArrayList<Integer> l=new ArrayList<>();
        ArrayList<Integer> c=new ArrayList<>();
            long A[]=new long[n];
            long B[]=new long[n];
                    long minA=Long.MAX_VALUE;
            long minB=Long.MAX_VALUE;
        for(int i=0;i<n;i++){
            A[i]=sc.nextLong();
            minA=Math.min(A[i],minA);}

              for(int i=0;i<n;i++) {
                  B[i] = sc.nextLong();
                  minB = Math.min(B[i], minB);
              }
              long count=0;
              for(int i=0;i<n;i++)
              {
               count+=Math.max(A[i]-minA,B[i]-minB);
              }





                  sb.append(count+"\n");














       // sb.append();






         }
        System.out.println(sb.toString());
    }
}












