#include <iostream>
//#include <fstream>
#include <sstream>
//#include <iomanip>
//#include <complex>
//#include <string>
#include <vector>
//#include <list>
//#include <deque>
//#include <stack>
//#include <queue>
//#include <set>
//#include <map>
//#include <bitset>
//#include <functional>
//#include <utility>
//#include <algorithm>
//#include <numeric>
//#include <typeinfo>
//#include <cstdio>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <climits>
//#include <ctime>

using namespace std;

//#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
//#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
//#define iter(c) __typeof((c).begin())
//#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
//#define allof(c) (c).begin(),(c).end()
//#define mp make_pair

//typedef unsigned int uint;
//typedef long long ll;
//typedef unsigned long long ull;
typedef vector<int> vi;
//typedef vector<vi> vvi;
typedef vector<string> vs;
//typedef pair<int,int> pii;

//ostream& operator<<(ostream& os,const vi& a)
//{
//	rep(i,a.size())
//		printf("%d%s",a[i],i==a.size()-1?"":" ");
//	return os;
//}

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

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]);
		cout<<solve(bars,s-1,g-1)<<endl;
	}
	
	return 0;
}