Problem: You are given a binary string of length , consisting of zeros and ones. You can perform the following operation exactly once:
- Choose an integer ().
- Reverse the substring . After this step, the string will become .
- Then, perform a cyclic shift of the string to the left times. After this step, the initial string will become .
For example, if you apply the operation to the string 110001100110 with , after the second step, the string will become 011001100110, and after the third step, it will become 001100110011.
A string is called -proper if two conditions are met:
- ;
- for any ().
For example, with , the strings 000, 111000111, and 111000 are -proper, while the strings 000000, 001100, and 1110000 are not.
You are given an integer , which is a divisor of . Find an integer () such that after performing the operation, the string becomes -proper, or determine that it is impossible. Note that if the string is initially -proper, you still need to apply exactly one operation to it.
Input Format: Each test consists of multiple test cases. The first line contains one integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers and (, ) — the length of the string and the value of . It is guaranteed that is a divisor of .
The second line of each test case contains a binary string of length , consisting of the characters 0 and 1.
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case, output a single integer — the value of to make the string -proper, or if it is impossible.
If there are multiple solutions, output any of them.
Note: In the first test case, if you apply the operation with , after the second step of the operation, the string becomes 11100001, and after the third step, it becomes 00001111. This string is -proper.
In the second test case, it can be shown that there is no operation after which the string becomes -proper.
In the third test case, if you apply the operation with , after the second step of the operation, the string becomes 100011100011, and after the third step, it becomes 000111000111. This string is -proper.
In the fourth test case, after the operation with any , the string becomes -proper.