Equality
题号:NC232082
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Yzk has an array a consisting of n integers . In one operation, he can select a continuous sub-array of exactly length k, then change all elements in the sub-array to the minimum element in this sub-array.
Please help him found the minimum number of operations to make all elements in the array a equal.

输入描述:

The first line contains one integer  --- the number of test cases.
The first line of each test case contains two integers --- the length of array a, and the length of sub-array Yzk should select.
The second line contains n integers . --- the elements of array a.
It's guaranteed that the sum of n over all test cases doesn't exceed ().

输出描述:

For each test case, output an integer in one line --- the minimum number of operations to make all elements in the array a equal. If it's impossible to do it, output -1.
示例1

输入

复制
4
5 3
3 4 1000000 5 3
5 3
1 2 1 3 1
2 1
1 1
2 1
1 2

输出

复制
2
1
0
-1

说明

In the first test case, we can do 2 operations as follows:
In the operation 1, select sub-array [a_1, a_2, a_3], the minimum element in [a_1,a_2,a_3] is a_1=3, then array a changes to [3,3,3,5,3].
In the operation 2, select sub-array [a_3, a_4, a_5], the minimum element in [a_3,a_4,a_5] is a_3=a_5=3, then array a changes to [3,3,3,3,3].