#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		int N=in();
		if(!N) break;
		vector<int> F(N,0);
		int start=in()-1;
		F[start] = 1;
		int goal=in()-1;
		int d=in();
		vector<string> S(d);
		REP(i,d){
			S[i]=in<string>();
		}
		
		int pos = start;
		vector<int> sh(d+1);
		sh[0] = pos;
		REP(i,d){
			if(pos>0 && S[i][pos-1]=='1') pos--;
			else if(pos<N-1 && S[i][pos]=='1') pos++;
			sh[i+1] = pos;
		}
		if(pos==goal){
			out(0);
			continue;
		}

		pos = goal;
		vector<int> gh(d+1);
		gh[0] = pos;
		REP(i,d){
			if(pos>0 && S[d-1-i][pos-1]=='1') pos--;
			else if(pos<N-1 && S[d-1-i][pos]=='1') pos++;
			gh[i+1] = pos;
		}
		reverse(ALL(gh));
		bool exist=false;
		REP(i,d){
			if(abs(sh[i]-gh[i])==1){
				pos = min(sh[i],gh[i]);
				if(S[i][pos]=='1' || (pos>0 && S[i][pos-1]=='1') || (pos<N-2 && S[i][pos+1]=='1')) continue;
				out(i+1,pos+1);
				exist = true;
				break;
			}
		}
		if(!exist) out(1);
	}

	return 0;
}
