#include <bits/stdc++.h>
using namespace std;
using ll = long long ; using ld = long double ;
constexpr ll mod = 1e9 + 7 ;
#define reverse(res) reverse(res.begin(),res.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define umap unordered_map
#define uset unordered_set
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pii pair<int,int>
#define ff first
#define ss second
#define lb lower_bound
#define vi vector<int>
#define int long long
#define ub upper_bound
#define contain(map, i) (map.find(i) == map.end())
#define maxele max_element
#define minele min_element
#define len(s) (s).length()
#define nl cout<<endl
#define rep(i, a, b) for(int i = a; i < b; i++)
#define trav(it , strt , end) for(auto it = strt; it != end ; it++ )
/*ll gcd(ll a ,ll b){
if(b==0)return a;
return gcd(b,a%b);
}
inttobin(int n){
string ans='';
while(n!=0){
if(n%2==1)ans+='1';
else ans+='0';
n=n/2;
}
reverse(ans);
cout<<ans<<endl;
}
int bintodec(string s){
int n=s.size();
for(int i=n-1;i>=0;i--){
if(s[i]=='1')num+=pow(2,i);
}
return num;
}
long long fastExpo(int a, int b,int m ) {
long long res = 1;
while(b > 0) {
if(b&1) {
res = (res)%m*(a)%m;
}
b = b >> 1;
a = ((a)%m *( a)%m)%m;
}
return res;
}
bool checkithsetbit(int n,int i){
return (n&(1<<i)!=0);
}
int setithbit(int n,int i){
return (n||(1<<i));
}
int clearithbit(int n,int i){
return(n&(~(1<<i)));
}
int toggleithbit(int n,int i){
return (n^(1<<i));
}
int addm(int a, int b)
{ return ((a % mod) + (b % mod)) % mod;}
int subtm(int a, int b)
{ return ((a % mod) - (b % mod) + mod) % mod;}
int mul(int a, int b)
{ return ((a % mod) * (b % mod)) % mod; }
int modInverse(int a)
{return fastpow(a, mod - 2);}
int divm(int a, int b)
{ return mul(a, modInverse(b));}*/
/************************************************/
void solve(){
int n, m, k;
cin >> n >> m >> k;
string s;
cin >> s;
int l=0;
int r=m-1;
if(k==1){
int op=0;
while(r+m<n){
if((l < n && s[l] == '1') || (r < n && s[r] == '1')){
if(r+m<n){
r=r+m;
l=(r-m+1);
}
}
else if(l==r){
op++;
if(r+m<n){
r=r+m;
l=(r-m+1);
}
}
else{
l++;
}
}
cout<<op<<"\n";
return;
}
else{
// int op=0;
// while(r+m<n){
// if ((l < n && s[l] == '1') || (r < n && s[r] == '1')) {
// if(r+m<n){
// r=r+m;
// l=(r-m+1);
// }
// }
// else if(l==r){
// op++;
// int p=(k/(m+1));
// if(r+(p+2)*m<n){
// r=r+(p+2)*m;
// l=(r-m+1);
// }
// }
// else{
// l++;
// }
// }
// cout<<op<<"\n";
// return;
// }
int op = 0;
while (r < n) {
// Check if the current segment [l, r] is weak
bool allWeak = true;
for (int i = l; i <= r; i++) {
if (s[i] == '1') {
allWeak = false;
break;
}
}
if (allWeak) {
// Strengthen the current segment
op++;
r += k; // Move r forward by k
l = r - m + 1; // Update l to the start of the new window
} else {
// Move the window forward
l++;
r = l + m - 1;
}
}
cout << op << "\n";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIGxsID0gbG9uZyBsb25nIDsgdXNpbmcgbGQgPSBsb25nIGRvdWJsZSA7CmNvbnN0ZXhwciBsbCBtb2QgPSAxZTkgKyA3IDsKI2RlZmluZSByZXZlcnNlKHJlcykgcmV2ZXJzZShyZXMuYmVnaW4oKSxyZXMuZW5kKCkpOwojZGVmaW5lIGFsbCh4KSAoeCkuYmVnaW4oKSwgKHgpLmVuZCgpCiNkZWZpbmUgcmFsbCh4KSAoeCkucmJlZ2luKCksICh4KS5yZW5kKCkKI2RlZmluZSB1bWFwIHVub3JkZXJlZF9tYXAKI2RlZmluZSB1c2V0IHVub3JkZXJlZF9zZXQKI2RlZmluZSBwYiB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QgYSwgaW50IGIsaW50IG0gKSB7CmxvbmcgbG9uZyAgcmVzID0gMTsKd2hpbGUoYiA+IDApIHsKaWYoYiYxKSB7CnJlcyA9IChyZXMpJW0qKGEpJW07CiB9CmIgPSBiID4+IDE7CmEgPSAoKGEpJW0gKiggYSklbSklbTsgCiB9CnJldHVybiByZXM7Cn0KYm9vbCBjaGVja2l0aHNldGJpdChpbnQgbixpbnQgaSl7CnJldHVybiAobiYoMTw8aSkhPTApOwp9CmludCBzZXRpdGhiaXQoaW50IG4saW50IGkpewpyZXR1cm4gKG58fCgxPDxpKSk7Cn0KaW50IGNsZWFyaXRoYml0KGludCBuLGludCBpKXsKcmV0dXJuKG4mKH4oMTw8aSkpKTsKfQppbnQgdG9nZ2xlaXRoYml0KGludCBuLGludCBpKXsKcmV0dXJuIChuXigxPDxpKSk7Cn0KaW50IGFkZG0oaW50IGEsIGludCBiKQp7IHJldHVybiAoKGEgJSBtb2QpICsgKGIgJSBtb2QpKSAlIG1vZDt9CmludCBzdWJ0bShpbnQgYSwgaW50IGIpCnsgcmV0dXJuICgoYSAlIG1vZCkgLSAoYiAlIG1vZCkgKyBtb2QpICUgbW9kO30KaW50IG11bChpbnQgYSwgaW50IGIpCnsgcmV0dXJuICgoYSAlIG1vZCkgKiAoYiAlIG1vZCkpICUgbW9kOyB9CmludCBtb2RJbnZlcnNlKGludCBhKQp7cmV0dXJuIGZhc3Rwb3coYSwgbW9kIC0gMik7fQppbnQgZGl2bShpbnQgYSwgaW50IGIpCnsgICAgcmV0dXJuIG11bChhLCBtb2RJbnZlcnNlKGIpKTt9Ki8KLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8Kdm9pZCBzb2x2ZSgpewogICAgIGludCBuLCBtLCBrOwogICAgICAgIGNpbiA+PiBuID4+IG0gPj4gazsKICAgICAgICBzdHJpbmcgczsKICAgICAgICBjaW4gPj4gczsKICAgICAgICBpbnQgbD0wOwogICAgICAgIGludCByPW0tMTsKICAgICAgICAKICAgICAgICBpZihrPT0xKXsKICAgICAgICAgICAgaW50IG9wPTA7CiAgICAgICAgCiAgICAgIHdoaWxlKHIrbTxuKXsKICAgICAgICAgCiAgICAgICAgCiAgICAgICAgICBpZigobCA8IG4gJiYgc1tsXSA9PSAnMScpIHx8IChyIDwgbiAmJiBzW3JdID09ICcxJykpewogICAgICAgICAgICAKICAgICAgICAgICAgaWYocittPG4pewogICAgICAgICAgICAgICAgcj1yK207CiAgICAgICAgICAgICAgICBsPShyLW0rMSk7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGVsc2UgaWYobD09cil7CiAgICAgICAgICAgIAogICAgICAgICAgICAgb3ArKzsKICAgICAgICAgICAgIGlmKHIrbTxuKXsKICAgICAgICAgICAgICAgIHI9cittOwogICAgICAgICAgICAgICAgbD0oci1tKzEpOwogICAgICAgICAgICAgICAgCiAgICAgICAgICAgICB9CiAgICAgICAgICAgICAKICAgICAgICAgICAgIAogICAgICAgICAgfQogICAgICAgICAgZWxzZXsKICAgICAgICAgICAgbCsrOwogICAgICAgICAgfQogICAgICAgICAgCiAgICAgIH0KICAgICAgY291dDw8b3A8PCJcbiI7CiAgICAgIHJldHVybjsKICAgICAgCiAgICB9CiAgICBlbHNlewogICAgLy8gICAgIGludCBvcD0wOwogICAgLy8gICAgICAgd2hpbGUocittPG4pewogICAgICAgICAKICAgICAgICAKICAgIC8vICAgICAgIGlmICgobCA8IG4gJiYgc1tsXSA9PSAnMScpIHx8IChyIDwgbiAmJiBzW3JdID09ICcxJykpIHsKICAgICAgICAgICAgCiAgICAvLyAgICAgICAgIGlmKHIrbTxuKXsKICAgIC8vICAgICAgICAgICAgIHI9cittOwogICAgLy8gICAgICAgICAgICAgbD0oci1tKzEpOwogICAgICAgICAgICAgICAgCiAgICAvLyAgICAgICAgICB9CiAgICAvLyAgICAgICB9CiAgICAvLyAgICAgICBlbHNlIGlmKGw9PXIpewogICAgLy8gICAgICAgICAgICAgb3ArKzsKICAgIC8vICAgICAgICAgICAgIGludCBwPShrLyhtKzEpKTsKICAgIC8vICAgICAgICAgICAgIGlmKHIrKHArMikqbTxuKXsKICAgIC8vICAgICAgICAgICAgICAgICByPXIrKHArMikqbTsKICAgIC8vICAgICAgICAgICAgICAgICBsPShyLW0rMSk7CgogICAgLy8gICAgICAgICAgICAgfQogICAgLy8gICAgICAgfQogICAgLy8gICAgICAgZWxzZXsKICAgIC8vICAgICAgICAgbCsrOwogICAgLy8gICAgICAgfQogICAgICAgICAgCiAgICAvLyAgICAgIH0KICAgIC8vICAgICAgY291dDw8b3A8PCJcbiI7CiAgICAvLyAgICAgIHJldHVybjsKICAgIC8vIH0KICAgIGludCBvcCA9IDA7CndoaWxlIChyIDwgbikgewogICAgLy8gQ2hlY2sgaWYgdGhlIGN1cnJlbnQgc2VnbWVudCBbbCwgcl0gaXMgd2VhawogICAgYm9vbCBhbGxXZWFrID0gdHJ1ZTsKICAgIGZvciAoaW50IGkgPSBsOyBpIDw9IHI7IGkrKykgewogICAgICAgIGlmIChzW2ldID09ICcxJykgewogICAgICAgICAgICBhbGxXZWFrID0gZmFsc2U7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgIH0KCiAgICBpZiAoYWxsV2VhaykgewogICAgICAgIC8vIFN0cmVuZ3RoZW4gdGhlIGN1cnJlbnQgc2VnbWVudAogICAgICAgIG9wKys7CiAgICAgICAgciArPSBrOyAvLyBNb3ZlIHIgZm9yd2FyZCBieSBrCiAgICAgICAgbCA9IHIgLSBtICsgMTsgLy8gVXBkYXRlIGwgdG8gdGhlIHN0YXJ0IG9mIHRoZSBuZXcgd2luZG93CiAgICB9IGVsc2UgewogICAgICAgIC8vIE1vdmUgdGhlIHdpbmRvdyBmb3J3YXJkCiAgICAgICAgbCsrOwogICAgICAgIHIgPSBsICsgbSAtIDE7CiAgICB9Cn0KY291dCA8PCBvcCA8PCAiXG4iOwogICAgfQp9CiAgICAKICAgIAoKCgpzaWduZWQgbWFpbigpIHsKICAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgICBjaW4udGllKCk7IGNvdXQudGllKDApOwogICAgICAjaWZuZGVmIE9OTElORV9KVURHRQogICAgICBmcmVvcGVuKCJpbnB1dC50eHQiLCAiciIsIHN0ZGluKTsKICAgICAgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKICAgICAgICNlbmRpZgogICAgICBpbnQgdDsKICAgICAgY2luPj50OwogICAgICB3aGlsZSh0LS0pewogICAgICAgIHNvbHZlKCk7CiAgICAgIH0KICAgIHJldHVybiAwOwp9