#include<cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,s,g,d;
	while(scanf("%d%d%d%d",&n,&s,&g,&d),n){
		s--,g--;
		int l[30][10]={0};
		int tr[30]={0};
		rep(i,d)rep(j,n-1)scanf("%1d",l[i]+j);
		
		int cl=g;
		for(int cd=d-1;cd>=0;cd--){
			if(cl<n-1&&l[cd][cl])cl++;
			else if(cl>0&&l[cd][cl-1])cl--;
			tr[cd]=cl;
		}
		if(cl==s){
			cout<<0<<endl; continue;
		}
		cl=s;
		for(int cd=0;cd<d;cd++){
			if(cl<n-1&&l[cd][cl])cl++;
			else if(cl>0&&l[cd][cl-1])cl--;
			if(tr[cd]==cl+1&&(cl<1||!l[cd][cl-1])&&(cl>=n-1||!l[cd][cl])&&(cl>=n-2||!l[cd][cl+1])){
				cout<<cd+1<<" "<<cl+1<<endl; goto NEXT;
			}
			if(tr[cd]==cl-1&&(cl<2||!l[cd][cl-2])&&(cl<1||!l[cd][cl-1])&&(cl>=n-1||!l[cd][cl])){
				cout<<cd+1<<" "<<cl+1<<endl; goto NEXT;
			}
		}
		cout<<1<<endl;
		NEXT:;
	}
	return 0;
}