You are given a garland consisting of n lamps. States of the lamps are represented by the string s of length n. The i-th character of the string s_i equals '0' if the i-th lamp is turned off or '1' if the i-th lamp is turned on. You are also given a positive integer k.

In one move, you can choose one lamp and change its state (i.e. turn it on if it is turned off and vice versa).

The garland is called k-periodic if the distance between each pair of adjacent turned on lamps is exactly k. Consider the case k=3. Then garlands "00010010", "1001001", "00010" and "0" are good but garlands "00101001", "1000001" and "01001100" are not. Note that the garland is not cyclic, i.e. the first turned on lamp is not going after the last turned on lamp and vice versa.

Your task is to find the minimum number of moves you need to make to obtain k-periodic garland from the given one.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 25~ 000) — the number of test cases. Then t test cases follow.

The first line of the test case contains two integers n and k (1 ≤ n ≤ 10^6; 1 ≤ k ≤ n) — the length of s and the required period. The second line of the test case contains the string s consisting of n characters '0' and '1'.

It is guaranteed that the sum of n over all test cases does not exceed 10^6 (∑ n ≤ 10^6).

Output

For each test case, print the answer — the minimum number of moves you need to make to obtain k-periodic garland from the given one.

Example

Input


6
9 2
010001010
9 3
111100000
7 4
1111111
10 3
1001110101
1 1
1
1 1
0


Output


1
2
5
4
0
0
import java.io.*;
import java.util.*;

public class E  implements Runnable{
	static int[][] dp;
	static int[][] pre;
	static int n,k;
	static char[] c;
	static int cnt(int t, int l, int r) {
		if  (l > r) return 0;
		if  (r  >=  n)  r  = n-1;
		if (l >= n) return 0;
		if (l == 0) return pre[t][r];
		return pre[t][r] - pre[t][l-1];
	}
	
	static  int solve(int pos, int used) {
		if  (pos  >=  n)  return 0;
		// DP of position, and have we placed a 1 yet.

		if (dp[pos][used] == -1) {
			// If we haven't placed a one, options are to place a 1 or not.
			// If we have placed a one, place 1 and pass it onto the next one (with mandatory zeroes), OR end here and just make the rest zeroes.
			if  (used  == 0) dp[pos][used]  = solve(pos+1,used) + cnt(1,pos,pos);
			else dp[pos][used]  =  cnt(1,pos,n);
			int  v2  = cnt(0,pos,pos);
			if  (k ==0) {
				v2 += solve(pos+1,1);
			}
			else {
				v2 += cnt(1,pos+1,pos+k)  +  solve(pos+k+1,1);
			}
			dp[pos][used]  =  Integer.min(dp[pos][used], v2);
		}
	
		return  dp[pos][used];
	}
	
	public static void main(String[] args) throws IOException {
		// br = new BufferedReader(new FileReader(".in"));
		// out = new PrintWriter(new FileWriter(".out"));
		new Thread(null, new E(), "peepee", 1<<28).start();
		
		
	}
	
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	static StringTokenizer st = new StringTokenizer("");
	static String read() throws IOException{return st.hasMoreTokens() ? st.nextToken():(st = new StringTokenizer(br.readLine())).nextToken();}
	static int readInt() throws IOException{return Integer.parseInt(read());}
	static long readLong() throws IOException{return Long.parseLong(read());}
	static double readDouble() throws IOException{return Double.parseDouble(read());}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		try {
			int t =readInt();
			while(t-->0) {
				n =readInt();
				k= readInt()-1;
				c = read().toCharArray();
				
				pre = new int[2][n];
				for (int i = 0; i < n; i++) {
					pre[c[i]-'0'][i]++;
					if (i >  0) {
						pre[0][i]  +=  pre[0][i-1];
						pre[1][i] += pre[1][i-1];
					}
				}
				dp  = new int[n][2];
				for  (int[] x: dp) Arrays.fill(x, -1);
				out.println(solve(0,0));
			}
			
			out.close();
		}
		catch (IOException e) {
			
		}
	}
	
}