#include<iostream>
#include<cstdio>

#define NMAX 10
#define DMAX 30

using namespace std;

int n,m,g,d;
int amida[DMAX*2][NMAX*2];
int lx=-1,ly=-1;
bool f;

void solve(int y,int x,bool line){
	if(f==true) return;
	if(y==d+1){
		if(x==g){
			if(line==true) cout<<ly<<" "<<lx<<endl;
			else cout<<"0"<<endl;
			f=true;
		}
		return;
	}
	if(amida[y][x]==1&&f==false){
		solve(y+1,x+1,line);
	}
	else if(line==false&&amida[y][x-1]!=1&&amida[y][x+1]!=1&&f==false){
		lx=x,ly=y;
		solve(y+1,x+1,true);
	}
	if(amida[y][x-1]==1&&f==false){
		solve(y+1,x-1,line);
	}
	else{
		if(x>=2&&f==false){
			if(line==false&&amida[y][x]!=1&&amida[y][x-2]!=1&&f==false){
				lx=x-1,ly=y;
				solve(y+1,x-1,true);
			}
		}
		else if(line==false&&amida[y][x]!=1&&f==false){
			lx=x-1,ly=y;
			solve(y+1,x-1,true);
		}
	}
	if(amida[y][x]!=1&&amida[y][x-1]!=1&&f==false) solve(y+1,x,line);
	return;
}

int main(void){
	std::ios_base::sync_with_stdio();

	while(1){
		cin>>n;
		if(n==0) break;
		cin>>m;
		cin>>g;
		cin>>d;
		getchar();
		for(int i=1;i<=d;i++){
			for(int j=1;j<=n-1;j++){
				amida[i][j]=getchar()-'0';
			}
			getchar();
		}
		for(int i=0;i<=d+1;i++) amida[i][0]=0,amida[i][n]=0;
		for(int i=0;i<=n;i++) amida[0][i]=0,amida[d+1][i]=0;
		f=false;
		solve(1,m,false);
		if(f==false) cout<<"0"<<endl;
	}
	return 0;
}