#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n,m;
int hit;
int d;
int line[31][31];

// ツ個サツ催敖づ個暗クツつォツ陛サツづゴツーツδ仰づつォツづゥツつゥツづつ、ツつゥ
bool isOk(){
	int rank=0;
	int p=m;
	for(int i = 0; i < d; i++){
		int left=p-1;
		int right=p;
		if(left>=0&&line[i][left]){
			p=left;
		}
		else if(right<n-1&&line[i][right]){
			p=right+1;
		}
	}
	// goal
	if(p==hit){
		return true;
	}
	else
		return false;
}

int main(){

	while(cin>>n&&n!=0){
		cin>>m>>hit>>d;
		hit--;
		m--;
		for(int i = 0; i < d; i++){
			for(int j = 0; j < n-1; j++){
				char ch;
				cin>>ch;
				line[i][j]=ch-'0';
			}
		}
		if(isOk())
			cout<<0<<endl;
		else{
			bool f=false;
			for(int i = 0; i < d; i++){
				for(int j = 0; j < n-1; j++){
					if(line[i][j]==0&&(j==0||line[i][j-1]==0)&&(j==n-1||line[i][j+1]==0)){
						line[i][j]=1;
						if(isOk()){
							cout<<i+1<<" "<<j+1<<endl;
							f=true;
							break;
						}
						line[i][j]=0;
					}
				}
				if(f)
					break;
			}
			if(!f){
				cout<<1<<endl;
			}
		}
	}

	return 0;
}