#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,sa,ga,d;
string s[31];
bool ch(){
  int sx=sa;
  r(i,d){
    if(!sx){
      if(s[i][0]=='1')sx++;
    }
    else if(sx==n-1){
      if(s[i][n-2]=='1')sx--;
    }
    else{
      if(s[i][sx]=='1')sx++;
      else if(s[i][sx-1]=='1')sx--;
    }
  }
  return sx==ga;
}
int main(){
  while(cin>>n,n){
  cin>>sa>>ga>>d;sa--;ga--;
  r(i,d)cin>>s[i];
  r(i,d)s[i]+='0';
  if(n==1){
    if(sa==ga)cout<<0<<endl;
    else cout<<1<<endl;
  }
  else{
  if(ch()){cout<<0<<endl;goto L;}//r(k,d)cout<<s[k]<<endl;
  r(i,d)r(j,n-1){
    if(!j){
      if(s[i][0]=='0'&&s[i][1]=='0'){
        s[i][0]='1';
        if(ch()){cout<<i+1<<' '<<j+1<<endl;goto L;}
        s[i][0]='0';
      }
    }
    else if(j==n-2){
      if(s[i][j]=='0'&&s[i][j-1]=='0'){
        s[i][j]='1';
        if(ch()){cout<<i+1<<' '<<j+1<<endl;goto L;}
        s[i][j]='0';
      }
    }
    else{
      if(s[i][j]=='0'&&s[i][j+1]=='0'&&s[i][j-1]=='0'){
        s[i][j]='1';
        if(ch()){cout<<i+1<<' '<<j+1<<endl;goto L;}
        s[i][j]='0';
      }
    }
  }
  cout<<1<<endl;L:;}
  }
}