// Author: Adrian Kuegel
// Date: September 8th, 2010
// Algorithm: greedy, efficient simulation using binary search
// Complexity: O(k log k)

#include <stdio.h>
#include <assert.h>
#include <algorithm>
using namespace std;

#define MAXN 1000000

int pos[MAXN];
char bridge[MAXN + 1];

int main() {
	int tc;
	scanf("%d", &tc);
	assert(tc >= 1 && tc <= 100);
	while(tc--) {
		int n, m, k;
		scanf("%d %d %d", &m, &n, &k);
		assert(m >= 1 && m <= n && n <= k && k <= MAXN);
		scanf("%s", bridge);
		assert(bridge[k] == 0);
		int l = 0;
		for (int i=0; i<k; ++i) {
			assert(bridge[i] == '1' || bridge[i] == '0');
			if (i < m || i >= k-m)
				assert(bridge[i] == '1');
			if (bridge[i] == '1')
				pos[l++] = i;
		}
		long long cnt = 0;
		bool possible = true;
		int where = m;
		while(where < l) {
			// move legs as most to the right as possible
			int upto = pos[where-m] + n;
			int i = lower_bound(pos, pos + l, upto) - pos;
			if (i == where) {
				possible = false;
				break;
			}
			cnt += m + pos[i - m] - pos[where - m];
			where = i;
		}
		if (!possible)
			puts("IMPOSSIBLE");
		else
			printf("%lld\n", cnt - (n-m));
	}
	return 0;
}
