#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> vs;
int d,n,m,p;
int amida(int x, vs &A){
	for(int i=0;i<d;i++)
		if(A[i][x]-'0')x++;
		else if(A[i][x-1]-'0')x--;
	return x;
}
int f(vs &A){
	for(int i=0;i<d;i++)
		for(int j=1;j<n;j++)
			if (A[i][j-1]=='0'&&A[i][j]=='0'&&A[i][j+1]=='0'){
				A[i][j]='1';
				if (amida(m,A)==p){
					cout<<i+1<<" "<<j<<endl;
					return 0;
				}
				A[i][j]='0';
			}
	cout<<1<<endl;
	return 0;
}
int main(){
	while (1){
		string s;
		cin>>n;
		if (n==0)break;
		vs A;
		cin>>m>>p>>d;
		getline(cin,s);
		for(int i=0;i<d;i++){
			getline(cin,s);
			A.push_back('0'+s+'0');
		}
		if (amida(m,A)==p)cout<<0<<endl;
		else f(A);
		A.clear();
	}
}