#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[11][30],b[10],m,n,o,d;
  char c;
  while(cin>>n&&n){
    cin>>m>>o>>d;
    memset(a,0,sizeof(a));
    for(i=0;i<d;i++){
      for(j=1;j<n;j++){
	cin>>c;
	a[j][i]=c-'0';
      }
    }
    memset(b,0,sizeof(b));
    b[o-1]=1;
    for(i=d-1;i>-1;i--){
      for(j=1;j<n;j++){
	if(a[j][i])
	  swap(b[j-1],b[j]);
      }
    }
    if(b[m-1])
      cout<<0<<endl;
    else{
      for(i=0;i<d;i++){
	for(j=1;j<n;j++){
	  if(a[j-1][i]==0&&a[j][i]==0&&a[j+1][i]==0){
	    a[j][i]=1;
	    memset(b,0,sizeof(b));
	    b[o-1]=1;
	    for(k=d-1;k>-1;k--){
	      for(l=1;l<n;l++){
		if(a[l][k])
		  swap(b[l-1],b[l]);
	      }
	    }
	    if(b[m-1])
	      break;
	    a[j][i]=0;
	  }
	}
	if(j!=n)
	  break;
      }
      if(i==d)
	cout<<1<<endl;
      else
	cout<<i+1<<" "<<j<<endl;
    }
  }
  return 0;
}