# Make that Array! solution codechef

Chef is given two arrays  and , each having  elements.

In one move, Chef can choose an index  ), get  points, and then swap  and .

For example: If Chef has the array –  and Chef chooses index  during his move, he will get  points and the new array will become

Can you help Chef in finding the maximum number of points he can get while converting the array  into array ?

It is guaranteed in the input that there exists a sequence of moves which can convert array  into .

## Make that Array! solution codechef

### Input Format

• The first line of input contains a single integer , denoting the number of testcases. The description of the  testcases follows.
• The first line of each test case contains a single integer  denoting the number of elements in  and .
• The second line of each test case contains  space separated integers .
• The third line of each test case contains  space separated integers .

### Output Format

For each test case, print a single line containing one integer, which is the maximum number of points that Chef can get while converting the array  into array

### Constraints

• The sum of  over all test cases does not exceed

Sample Input 1 Make that Array! solution codechef

3
2
1 2
2 1
3
3 2 1
1 2 3
3
1 2 3
1 2 3


### Sample Output 1 Make that Array! solution codechef

-1
4
0


### Explanation Make that Array! solution codechef

Test Case : Chef can choose  in the first move, get  points and swap  and . After this move,  is converted into . We can prove that there exists no other sequence of moves which can result in higher score while converting  into .

## Make that Array! solution codechef

Test Case : One possible sequence of moves is the following:

• Choose . Total points , and  will become .
• Choose . Total points , and  will become .
• Choose . Total points , and  will become .

There are other possible sequences of moves which can result in total  points, but no such sequence exists which can result in more than  points, and simultaneously convert  into .