#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)

typedef vector<int> vi;
typedef vector<string> vs;

string to_string(int a,int b)
{
	ostringstream oss;
	oss<<a<<" "<<b;
	return oss.str();
}

//  Ý¾­¶ÌoÍÌ¶©çgÔÚðÔ·
int simulate(vs& bars,int g)
{
	vi lines(bars[0].size()+1);
	rep(i,lines.size())
		lines[i]=i;
	rep(i,bars.size()){
		rep(j,bars[i].size())
			if(bars[i][j]=='1')
				swap(lines[j],lines[j+1]);
	}
	return lines[g];
}

// iÆc_Í0-origin
string solve(vs& bars,int s,int g)
{
	if(simulate(bars,g)==s)
		return "0";
	
	rep(i,bars.size()){
		rep(j,bars[i].size()){
			bool ok=false;
			if(bars[i][j]=='0'){
				if(j==0 && bars[i][j+1]=='0') // ¶[
					ok=true;
				else if(j==bars[i].size()-1 && bars[i][j-1]=='0') // E[
					ok=true;
				else if(bars[i][j-1]=='0' && bars[i][j+1]=='0') // »êÈO
					ok=true;
			}
			if(ok){
				bars[i][j]='1';
				if(simulate(bars,g)==s)
					return to_string(i+1,j+1);
				bars[i][j]='0';
			}
		}
	}
	
	return "1";
}

int main()
{
	for(int l;cin>>l,l;){
		int s,g,b;
		cin>>s>>g>>b;
		//cin.get();
		vs bars(b);
		rep(i,b)
			//getline(cin,bars[i]);
			cin>>bars[i];
		cout<<solve(bars,s-1,g-1)<<endl;
	}
	
	return 0;
}