#P1891E. Brukhovich and Exams

    ID: 8779 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>brute forcegreedyimplementationmathsortings

Brukhovich and Exams

No submission language available for this problem.

Description

The boy Smilo is learning algorithms with a teacher named Brukhovich.

Over the course of the year, Brukhovich will administer nn exams. For each exam, its difficulty aia_i is known, which is a non-negative integer.

Smilo doesn't like when the greatest common divisor of the difficulties of two consecutive exams is equal to 11. Therefore, he considers the sadness of the academic year to be the number of such pairs of exams. More formally, the sadness is the number of indices ii (1in11 \leq i \leq n - 1) such that gcd(ai,ai+1)=1gcd(a_i, a_{i+1}) = 1, where gcd(x,y)gcd(x, y) is the greatest common divisor of integers xx and yy.

Brukhovich wants to minimize the sadness of the year of Smilo. To do this, he can set the difficulty of any exam to 00. However, Brukhovich doesn't want to make his students' lives too easy. Therefore, he will perform this action no more than kk times.

Help Smilo determine the minimum sadness that Brukhovich can achieve if he performs no more than kk operations.

As a reminder, the greatest common divisor (GCD) of two non-negative integers xx and yy is the maximum integer that is a divisor of both xx and yy and is denoted as gcd(x,y)gcd(x, y). In particular, gcd(x,0)=gcd(0,x)=xgcd(x, 0) = gcd(0, x) = x for any non-negative integer xx.

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. The descriptions of the test cases follow.

The first line of each test case contains two integers nn and kk (1kn1051 \leq k \leq n \leq 10^5) — the total number of exams and the maximum number of exams that can be simplified, respectively.

The second line of each test case contains nn integers a1,a2,a3,,ana_1, a_2, a_3, \ldots, a_n — the elements of array aa, which are the difficulties of the exams (0ai1090 \leq a_i \leq 10^9).

It is guaranteed that the sum of nn across all test cases does not exceed 10510^5.

For each test case, output the minimum possible sadness that can be achieved by performing no more than kk operations.

Input

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. The descriptions of the test cases follow.

The first line of each test case contains two integers nn and kk (1kn1051 \leq k \leq n \leq 10^5) — the total number of exams and the maximum number of exams that can be simplified, respectively.

The second line of each test case contains nn integers a1,a2,a3,,ana_1, a_2, a_3, \ldots, a_n — the elements of array aa, which are the difficulties of the exams (0ai1090 \leq a_i \leq 10^9).

It is guaranteed that the sum of nn across all test cases does not exceed 10510^5.

Output

For each test case, output the minimum possible sadness that can be achieved by performing no more than kk operations.

Sample Input 1

9
5 2
1 3 5 7 9
5 2
3 5 7 9 11
8 2
17 15 10 1 1 5 14 8
5 3
1 1 1 1 1
5 5
1 1 1 1 1
19 7
1 1 2 3 4 5 5 6 6 7 8 9 10 1 1 1 2 3 1
15 6
2 1 1 1 1 2 1 1 2 1 1 1 2 1 2
5 2
1 1 1 1 2
5 2
1 0 1 0 1

Sample Output 1

1
0
2
2
0
5
5
2
1

Note

In the first test case, a sadness of 11 can be achieved. To this, you can simplify the second and fourth exams. After this, there will be only one pair of adjacent exams with a greatest common divisor (GCD) equal to one, which is the first and second exams.

In the second test case, a sadness of 00 can be achieved by simplifying the second and fourth exams.