#include <iostream>

using namespace std;

int map[30][10];
int n, d, m, goal;

bool ok() {
	int pos = m-1;
	for(int y = 0; y < d; y++) {
		if(pos < d-1 && map[y][pos]) pos++;
		else if(pos > 0 && map[y][pos-1]) pos--;
	}
	//cout << pos << endl;
	if(pos == goal-1) return true;
	return false;
}

bool write(int y,int x) {
	if(map[y][x] == 1) return false;
	if((x < d-1 && map[y][x+1] == 0) || x == d-1) {
		if((0 < x && map[y][x-1] == 0) || x == 0) {
			return true;
		}
	}
	return false;
}

int main(void)
{
	while(1) {
		cin >> n;
		if(n == 0) break;
		cin >> m >> goal >> d;
		
		for(int y = 0; y < 30; y++) for(int x = 0; x < 10; x++) map[y][x] = 0;
		
		string str;
		for(int y = 0; y < d; y++) {
			cin >> str;
			for(int x = 0; x < n-1; x++) {
				map[y][x] = str[x] - '0';
			}
		}
		
		if(ok()) {
			cout << 0 << endl;
			continue;
		}
		
		bool clear = false;
		for(int y = 0; y < d && !clear; y++) {
			for(int x = 0; x < n-1 && !clear; x++) {
				if(write(y,x)) {
					map[y][x] = 1;
					if(ok()) {
						cout << y+1 << " " << x+1 << endl;
						clear = true;
					}
					map[y][x] = 0;
				}
			}
		}
	
		if(!clear)  cout << 1 << endl;
	}
	
	return 0;
}