__ Problem:-__

Alice and Bob are very good friends. They keep on playing some strange games. Today Alice came up with a new game, in which each player gets cards at the start. Each card has it's value printed on it.

The game proceeds as each player chooses a random card and shows it's value. The player having card with higher value wins. As Alice came up with this game, he wants to ensure his win. So he starts to increase value of some cards using an algorithm. To increase the value of a card by , the running time of algorithm is seconds.

Find the minimum running time of algorithm, ensuring the win of Alice.

Input:

First line of input contains an integer denoting the number of TestCases.

First line of Each testcase contains two Integers and .

Next two lines of each TestCase contains integers, each denoting value of cards of Alice and Bob respectively.

Output:

Print a single line for each TestCase, running time of algorithm to ensure the win for Alice.

Constraints:

There are 3 TestCases.

In 1^{st} TestCase there are 5 cards and the time required to increase the value of a card by one is 3.

Initial values on Alice's cards are .

If he converts the the above array into Then it's guranteed that he will win with minimum running time of algorithm.

For this conversion the running time of algorithm for:

1^{st }element :-

2^{nd} element :-

3^{rd} element :-

4^{th }element :-

5^{th} element :-

Hence the total running time of algorithm for 1^{st} TestCase is

__Code:-__

## 0 Comments