#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

bool solve(const std::vector<std::string> &hlines, int n, int m, int g, int d){
	bool ret = false;
	int cur_p = m - 1;

	for(int y = 0; y < d; y++){
		if(cur_p >= 1 && hlines[y][cur_p - 1] == '1'){
			cur_p--;
		}
		else if(hlines[y][cur_p] == '1'){
			cur_p++;
		}
	}
	ret = (cur_p + 1 == g);

	return ret;
}

int main(int argc, char **argv){
	int n, m, g, d;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> n){
#else
	while(std::cin >> n){
#endif
		if(n == 0){ break; }
		std::vector<std::string> hlines;

#if INPUT_FROM_FILE
		ifs >> m >> g >> d;
#else
		std::cin >> m >> g >> d;
#endif

#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		for(int y = 0; y < d; y++){
#if INPUT_FROM_FILE
			std::getline(ifs, buf);
#else
			std::getline(std::cin, buf);
#endif
			hlines.push_back(buf);
		}

		if(solve(hlines, n, m, g, d)){
			std::cout << "0" << std::endl;
		}
		else{
			bool is_solved = false;
			for(int y = 0; y < d; y++){
				for(int x = 0; x < n - 1; x++){
					if(hlines[y][x] == '0'){
						if((x == 0 || (x > 0 && hlines[y][x - 1] == '0')) && (x == n - 2 || (x <= n - 2 && hlines[y][x + 1] == '0'))){
							std::vector<std::string> tmp = hlines;

							tmp[y][x] = '1';
							if(solve(tmp, n, m, g, d)){
								is_solved = true;
								std::cout << y + 1 << " " << x + 1 << std::endl;
								y = d;
								break;
							}
						}
					}
				}
			}

			if(!is_solved){
				std::cout << "1" << std::endl;
			}
		}
	}



#if INPUT_FROM_FILE
	//fclose(fp);
#endif
	return 0;
}

