#include<iostream>
#include<string>
using namespace std;
int n,m,r,d,f[12][30]={0};
bool ans();
int main(){
  while(cin >>n,n){
    cin >>m>>r>>d;
    string s;
    bool fl = false;
    for(int i=0; i<d; i++){
      cin >>s;
      for(int j=0; j<n-1; j++) f[j+1][i] = s[j]-'0';
    }
    if(ans()){cout <<"0"<<endl;fl = true;}
    else{
      for(int i=0; i<d; i++){
	for(int j=1; j<n; j++){
	  if(f[j][i] == 0 && f[j-1][i] == 0 && f[j+1][i] == 0){
	    f[j][i] = 1;
	    if(ans() && !fl){cout <<i+1<<" "<<j<<endl;fl = true;}
	    f[j][i] = 0;
	  }
	}
      }
    }
    if(!fl) cout <<"1"<<endl;
  }
  return 0;
}
bool ans(){
  int x=m;
  for(int i=0; i<d; i++){
    if(f[x-1][i] == 1) x--;
    else if(f[x][i] == 1) x++;
  }
  return x == r;
}