// NWERC'10 solution for problem 'Wormly'
// Jaap Eldering

#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cassert>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

int main()
{
	int run, nruns;

	cin >> nruns;

	for(run=1; run<=nruns; run++) {
		int B, L, P;
		string planks;

		cin >> L >> B >> P >> planks;

		assert( planks.size()==P );

		long long res = 0;

		int bubblepos = B-1;
		int leg1pos = 0;
		int legLpos = L-1;

		while ( leg1pos<P-L ) {

			if ( leg1pos>bubblepos-B+1 ) {
				int newpos = min(P-1,leg1pos + B - 1);
				res += newpos - bubblepos;
				bubblepos = newpos;
			}

			int next;
			for(next = bubblepos; next>legLpos && planks[next]=='0'; next--);
			if ( next<=legLpos ) goto impossible;

			int cross = 0;
			for(; legLpos<next; legLpos++) if ( planks[legLpos]=='1' ) cross++;

			for(; cross>0 || planks[leg1pos]=='0'; leg1pos++)
				if ( planks[leg1pos]=='1' ) cross--;

			res += L;
		}

		cout << res << endl;
		continue;

	  impossible:
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}
