#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;

int getdst(const vs& amida,int src)
{
	int h=amida.size(),w=amida[0].size();
	rep(i,h){
		if(src!=1 && amida[i][src-2]=='1')
			src--;
		else if(src!=w+1 && amida[i][src-1]=='1')
			src++;
	}
	return src;
}

void solve(vs& amida,int src,int dst)
{
	if(getdst(amida,src)==dst){
		cout<<0<<endl;
		return;
	}
	
	int h=amida.size(),w=amida[0].size();
	if(w==1){
		rep(i,h)
			if(amida[i][0]=='0'){
				cout<<i+1<<" "<<1<<endl;
				return;
			}
		cout<<1<<endl;
		return;
	}
	
	rep(i,h)
		rep(j,w){
			if(amida[i][j]=='1')
				continue;
			
			bool ok=false;
			if(j==0){
				if(amida[i][j+1]=='0'){
					amida[i][j]='1';
					if(getdst(amida,src)==dst)
						ok=true;
				}
			}
			else if(j==w-1){
				if(amida[i][j-1]=='0'){
					amida[i][j]='1';
					if(getdst(amida,src)==dst)
						ok=true;
				}
			}
			else{
				if(amida[i][j-1]=='0' && amida[i][j+1]=='0'){
					amida[i][j]='1';
					if(getdst(amida,src)==dst)
						ok=true;
				}
			}
			amida[i][j]='0';
			
			if(ok){
				cout<<i+1<<" "<<j+1<<endl;
				return;
			}
		}
	
	cout<<1<<endl;
}

int main()
{
	for(int n;cin>>n,n;){
		int src,dst,h;
		cin>>src>>dst>>h;
		vs amida(h);
		rep(i,h)
			cin>>amida[i];
		solve(amida,src,dst);
	}
	
	return 0;
}