#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();
}

string solve(vs& bars,int s,int g)
{
	int l=bars[0].size()+1;
	int b=bars.size();
	vi lines(l);
	
	rep(i,l)
		lines[i]=i;
	rep(i,b){
		rep(j,l-1)
			if(bars[i][j]=='1')
				swap(lines[j],lines[j+1]);
	}
	if(lines[g]==s)
		return "0";
	
	vi lines2(l);
	rep(i,l)
		lines2[i]=i;
	rep(i,b){
		rep(j,l-1){
			bool ok=false;
			if(bars[i][j]=='0'){
				if(j==0 && bars[i][j+1]=='0')
					ok=true;
				if(j==l-2 && bars[i][j-1]=='0')
					ok=true;
				if(bars[i][j-1]=='0' && bars[i][j+1]=='0')
					ok=true;
			}
			//printf("%d %d: %s\n",i,j,ok?"true":"false");
			if(ok)
				if(lines2[j]==s && lines2[j+1]==lines[g] || lines2[j]==lines[g] && lines2[j+1]==s)
					return to_string(i+1,j+1);
		}
		rep(j,l-1)
			if(bars[i][j]=='1')
				swap(lines2[j],lines2[j+1]);
	}
	
	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;
}