For given two sets S and T of numbers, let a matching of S and T be a set of pairs (s, t) , s ∈ S , t ∈ T such that each number in S is paired with at least one number in T and each number in T is paired with at least one number in S . For example, the following is a matching of two sets S = {2, 8, 9, 10, 11} , T = {0, 3, 4, 6, 7, 11} :
M1 = {(2, 0),(2, 3),(2, 4),(8, 6),(9, 7),(10, 11),(11, 11)}
Whereas the following is not a matching of S and T ,
M2 = {(2, 0),(8, 3),(9, 4),(10, 6),(11, 7)}
since the number 11 in set T is not paired with any number in S .
For a pair (a, b) in a matching, the cost of the pair is defined to be the absolute value of the difference between a and b . The cost of a matching is the sum of the cost of all pairs in the matching. For example, the cost of the matching M1 is 10.
Given two sets of numbers, compute the minimum cost matching of the two sets. For example, the matching M1 is a minimum cost matching of the given two sets S and T .
Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case consists of three lines. The first line of each test case contains two integers. The first integer, n1 , is the number of integers in the first set, and the second integer, n2 , is the number of integers in the second set, where 1 ≤ n1, n2 ≤ 50, 000 . The second line of each test case contains n1 integers for the first set and the third line contains n2 integers for the second set. The integers in each set are arranged in increasing order. All input integers are between 0 and 100,000.
Your program is to write to standard output. Print exactly one line for each test case. The line should contain the cost of the minimum cost matching of the two sets of integers.