#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int a,b,c,n;
bool func(vector<string>in){
  bool h=false;
  int now=b-1;
  rep(i,n){
    if(now&&in[i][now-1]=='1')now--;
    else if(now!=a-1&&in[i][now]=='1')now++;
  }
  if(now==c-1)h=true;
  return h;
}
int main(){
  while(cin>>a,a){
    cin>>b>>c>>n;
    vector<string>in(n);
    rep(i,n)cin>>in[i];
    if(func(in)){
      cout<<0<<endl;
      continue;
    }
    bool h=false;
    rep(j,n)rep(i,a-1){
      if(in[j][i]=='1')continue;
      if(i&&in[j][i-1]=='1')continue;
      if(i!=a-1&&in[j][i+1]=='1')continue;
      //cout<<"!"<<j+1<<" "<<i+1<<endl;
      in[j][i]='1';
      if(func(in)){
	cout<<j+1<<" "<<i+1<<endl;
	j=n;
	h=true;
	break;
      }
      in[j][i]='0';
    }
    if(!h)cout<<1<<endl;
  }
}