#include <iostream>
using namespace std;

struct point{
	char l;
	char r;
};

int move(point area[10][30], int h, int w, int m){
	int goal = m - 1;
	for(int i = 0; i < h; i++){
		if(area[i][goal].l == '1'){
			goal--;
		}else if(area[i][goal].r == '1'){
			goal++;
		}
	}
	return goal + 1;
}

int main(){
	const int maxw = 10;
	const int maxh = 30;
	int n, m, g, d;
	char c;
	point area[maxw][maxh];
	cin >> n >> m >> g >> d;
	for(int i = 0; i < d; i++){
		for(int j = 0; j < n; j++){
			area[i][j].l = '0';
			area[i][j].r = '0';
		}
	}
	for(int i = 0; i < d; i++){
		for(int j = 1; j < n; j++){
			cin >> c;
			if(c == '1'){
				area[i][j-1].r = '1';
				area[i][j].l = '1';
			}
		}
	}
	if(move(area, d, n, m) == g){
		cout << 0 << endl;
	}else{
		int i = 0, j = 0, count = 0;
		for(;i < d; i++){
			j = 0;
			for(;j < n-1; j++){
				if(area[i][j].l == '0' && area[i][j+1].r == '0' && area[i][j].r == '0'){
					area[i][j].r ='1'; 
					area[i][j+1].l = '1';
					if(move(area, d, n, m) == g){
						count++;
						break;
					}
					area[i][j].r = '0';
					area[i][j+1].l = '0';
				}
			}
			if(count == 1) break;
		}
		if(i == d && j == n - 1) cout << 1 << endl;
		else cout << i+1 << " " << j+1 << endl;
	}
	return 0;
}