#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);++i)
#define reps(i,j,k) for(int i=j;i<k;++i)
typedef long long ll;
typedef unsigned long long ull;

char stage[100][100];
int x,y;
int n,m,g,d;

int check(int now){
	rep(i,d){
		//cout << now << endl;
		if(now == 0 && stage[i][0] == '1'){
			now++;
		}
		else if(now == 0 && stage[i][0] == '0')continue;
		else if(now == n-1 && stage[i][n-2] == '1'){
			now--;
		}
		else if(now == n-1 && stage[i][n-2] == '0')continue;
		else if(stage[i][now-1] == '1'){
			now--;
		}
		else if(stage[i][now] == '1'){
			now++;
		}
	}
	//cout << "-------------------" << now << endl;
	return now;
}
int solve(){
	int now = m-1;
	if(check(now) == g-1)return 0;
	rep(i,d){
		if(stage[i][0] == '0' && stage[i][1] == '0'){
			stage[i][0] = '1';
			y = i+1,x = 1;
			//cout << "D:" << y << " " << x << endl;
			if(check(now) == g-1)return -1;
			stage[i][0] = '0';
		}
		reps(j,1,n-2){
			if(stage[i][j-1] == '0' && stage[i][j] == '0' && stage[i][j+1] == '0'){
				stage[i][j] = '1';
				y = i+1,x = j+1;
				//cout << "D:" << y << " " << x << endl;
				if(check(now) == g-1)return -1;
				stage[i][j] = '0';
			}
		}
		if(stage[i][n-2] == stage[i][n-3] && stage[i][n-3] == '0'){
			stage[i][n-2] = '1';
			y = i+1,x = n-1;
			//cout << "D:" << y << " " << x << endl;
			if(check(now) == g-1)return -1;
			stage[i][n-2] = '0';
		}
	}
	return 1;
}
int main(){
	while(scanf("%d",&n),n){
		scanf("%d%d%d",&m,&g,&d);
		memset(stage,0,sizeof(stage));
		rep(i,d){
			scanf("%s",stage[i]);
		}
		int res = solve();
		if(res == 0)puts("0");
		else if(res == 1)puts("1");
		else if(res == -1){
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}