AlgoUniversity
  • Go Back
Discussion
Dom And Parts :

Author

hardik kapoor

Difficulty Level : Medium

Submissions : 556

Asked In : Navi

Marks :10

: 6 | : 1

Dom is out to buy parts at his favourite garage. Each part has a strength value associated with it. As we know, while buying parts, one has to keep in mind the symmetry and stability of the car. For these reasons, Dom wants to buy the parts in pairs, and needs P (independent) pairs of parts for his car.

Also, whenever he buys a pair, there is an associated instability with it, which is defined as the absolute difference between the strength value of the parts , i.e - if he choses parts with strength 4 and 3, the instability is 1.

Help Dom buy P (independent) pairs from the N parts such that the effective instability is minimised.

The effective instability is the max instability of all pairs.

Input

The first line contains T (1 <= T <= 1e5) - The number of test cases

First line of each test case contains N (2 <= N <= 1e5) and P (1 <= P <= N/2).

Second line contains N space separated integers, containing A[i] (1 <= A[i] <= 1e9) - the strength values of the parts.

Sum of N over all test cases does not exceed 1e5.

Output

Single line containing single integer, the minimum effective stability.

Example

Input
3
5 2
1 2 3 4 5
10 3
1 5 6 2 4 5 1 10 9 59
10 4
1 5 6 2 4 5 1 10 9 59
Output
1
1
1

Note

In the first test case, we can take (1,2),(4,5) as the two pairs, instability will be 1,1 respectively, hence effective instability=1.

In the second test case, we can take (5,6),(4,5),(1,1) as the three pairs, instability will be 1,1,0 respectively, hence effective instability=1.

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.