/* NWERC 2010: Sample solution to "Wormly"
 * Author: Sean Lip
 *
 * Algorithm: greedy. Move all legs, then body. Repeat.
 */

#include <iostream>
#include <algorithm>

using namespace std;

int plankLocs[1000000];

int main()
{
	int T;
	cin >> T;
	for(int i = 0; i < T; i++)
	{
		int N,M,K;
		cin >> N >> M >> K;
		
		if(N < 1 || M < N || K < M || K > 1000000)
		{
			cout << "Bad bounds (N,M,K) for test number " << i+1 << endl;
			return 1;
		}
		
		int numPlanks = 0;
		
		for(int j = 0; j < K; j++)
		{
			char c;
			cin >> c;
			if(c == '1')
				plankLocs[numPlanks++] = j;
			if((j <= N-1 || j >= K-N+1) && c == '0')
			{
				cout << "Error: The left- and right-most m planks must be present.\n";
				return 1;
			}
		}

		if(M == K && N == M)
		{
			cout << 0 << endl;
			continue;
		}
	
		int head = M-1;
		int firstLeg = N-1;
		int lastLeg = 0;
		
		long long ans = 0;
		int bad = 0;
				
		while(head < K-1)
		{
			int newFirstLegInd = upper_bound(plankLocs,plankLocs+numPlanks,head) - plankLocs - 1;

			if(plankLocs[newFirstLegInd] == firstLeg)
			{
				bad = 1;
				break;
			}
	
			firstLeg = plankLocs[newFirstLegInd];
			lastLeg = plankLocs[newFirstLegInd - N + 1];
			ans += N;
			
			int newHead = min(K-1,lastLeg + M - 1);
			ans += newHead - head;
			head = newHead;
		}

		if(bad)
			cout << "IMPOSSIBLE\n";
		else
			cout << ans + N << endl;
	}
	return 0;
}
