#include <iostream>
#include <string>

void show (int* a, int n)
{
	for (int i=0; i<n; i++) {
		std::cout << a[i] << ",";
	}
	std::cout << std::endl;
}

int main()
{
	int n, m, star, d;
	while (true) {
		std::cin >> n;
		
		if (n==0) break;
		
		std::cin >> m;
		std::cin >> star;
		std::cin >> d;
		
		std::string* bars = new std::string[d];
		for (int i=0; i<d; i++) std::cin >> bars[i];
		
		int* up_to_down = new int[d+2];
		int* down_to_up = new int[d+2];
		
		
		up_to_down[0] = m;
		for (int i=1; i<=d; i++) {
			bool left  = (up_to_down[i-1] >= 2   && bars[i-1][up_to_down[i-1]-2] == '1');
			bool right = (up_to_down[i-1] <= n-1 && bars[i-1][up_to_down[i-1]-1] == '1');
			if (left) up_to_down[i] = up_to_down[i-1] - 1;
			else if (right) up_to_down[i] = up_to_down[i-1] + 1;
			else up_to_down[i] = up_to_down[i-1];
		}
		up_to_down[d+1] = up_to_down[d];
		
		if (up_to_down[d+1] == star) { // can reach the star
			std::cout << 0 << std::endl;
		}
		else { // cannot reach the star
			down_to_up[d+1] = star;
			for (int i=d; i>=1; i--) {
				bool left  = (down_to_up[i+1] >= 2   && bars[i-1][down_to_up[i+1]-2] == '1');
				bool right = (down_to_up[i+1] <= n-1 && bars[i-1][down_to_up[i+1]-1] == '1');
				if (left) down_to_up[i] = down_to_up[i+1] - 1;
				else if (right) down_to_up[i] = down_to_up[i+1] + 1;
				else down_to_up[i] = down_to_up[i+1];
			}
			down_to_up[0] = down_to_up[1];
			
			bool reachable = false;
			for (int i=1; i<=d; i++) {
				if (up_to_down[i-1] == up_to_down[i] && down_to_up[i] == down_to_up[i+1]) {
					if (up_to_down[i] - down_to_up[i] == 1) {
						std::cout << i << " " << down_to_up[i] << std::endl;
						reachable = true;
						break;
					}
					else if (down_to_up[i] - up_to_down[i] == 1) {
						std::cout << i << " " << up_to_down[i] << std::endl;
						reachable = true;
						break;
					}
				}
			}
			if (!reachable) std::cout << 1 << std::endl;
		}
		
		//show(up_to_down, d);
		//show(down_to_up, d);
		
		delete[] bars;
		
		delete[] up_to_down;
		delete[] down_to_up;
	}
	return 0;
}
	
