#P1706D1. Chopping Carrots (Easy Version)

    ID: 7782 Type: RemoteJudge 4000ms 64MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>binary searchbrute forceconstructive algorithmsdpgreedynumber theory

Chopping Carrots (Easy Version)

No submission language available for this problem.

Description

This is the easy version of the problem. The only difference between the versions is the constraints on nn, kk, aia_i, and the sum of nn over all test cases. You can make hacks only if both versions of the problem are solved.

Note the unusual memory limit.

You are given an array of integers a1,a2,,ana_1, a_2, \ldots, a_n of length nn, and an integer kk.

The cost of an array of integers p1,p2,,pnp_1, p_2, \ldots, p_n of length nn is max1in(aipi)min1in(aipi).\max\limits_{1 \le i \le n}\left(\left \lfloor \frac{a_i}{p_i} \right \rfloor \right) - \min\limits_{1 \le i \le n}\left(\left \lfloor \frac{a_i}{p_i} \right \rfloor \right).

Here, xy\lfloor \frac{x}{y} \rfloor denotes the integer part of the division of xx by yy. Find the minimum cost of an array pp such that 1pik1 \le p_i \le k for all 1in1 \le i \le n.

The first line contains a single integer tt (1t1001 \le t \le 100) — the number of test cases.

The first line of each test case contains two integers nn and kk (1n,k30001 \le n, k \le 3000).

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1a1a2an30001 \le a_1 \le a_2 \le \ldots \le a_n \le 3000).

It is guaranteed that the sum of nn over all test cases does not exceed 30003000.

For each test case, print a single integer — the minimum possible cost of an array pp satisfying the condition above.

Input

The first line contains a single integer tt (1t1001 \le t \le 100) — the number of test cases.

The first line of each test case contains two integers nn and kk (1n,k30001 \le n, k \le 3000).

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1a1a2an30001 \le a_1 \le a_2 \le \ldots \le a_n \le 3000).

It is guaranteed that the sum of nn over all test cases does not exceed 30003000.

Output

For each test case, print a single integer — the minimum possible cost of an array pp satisfying the condition above.

Samples

Sample Input 1

7
5 2
4 5 6 8 11
5 12
4 5 6 8 11
3 1
2 9 15
7 3
2 3 5 5 6 9 10
6 56
54 286 527 1436 2450 2681
3 95
16 340 2241
2 2
1 3

Sample Output 1

2
0
13
1
4
7
0

Note

In the first test case, the optimal array is p=[1,1,1,2,2]p = [1, 1, 1, 2, 2]. The resulting array of values of aipi\lfloor \frac{a_i}{p_i} \rfloor is [4,5,6,4,5][4, 5, 6, 4, 5]. The cost of pp is max1in(aipi)min1in(aipi)=64=2\max\limits_{1 \le i \le n}(\lfloor \frac{a_i}{p_i} \rfloor) - \min\limits_{1 \le i \le n}(\lfloor \frac{a_i}{p_i} \rfloor) = 6 - 4 = 2. We can show that there is no array (satisfying the condition from the statement) with a smaller cost.

In the second test case, one of the optimal arrays is p=[12,12,12,12,12]p = [12, 12, 12, 12, 12], which results in all aipi\lfloor \frac{a_i}{p_i} \rfloor being 00.

In the third test case, the only possible array is p=[1,1,1]p = [1, 1, 1].