#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int n,m,g,d;
int mp[30][9];

bool calc(){
  int p = m;
  REP(i,d){
    if(p!=0 && mp[i][p-1]==1){
      --p;
    }else if(p!=n-1 && mp[i][p]==1){
      ++p;
    }
  }
  return p==g;
}

int main(){
  while(true){
    cin>>n;
    if(n==0)break;
    cin>>m>>g>>d;
    --m; --g;
    REP(i,d){
      int x;
      cin>>x;
      REPR(j,n){
        mp[i][n-1-j] = x%10;
        x/=10;
      }
    }
    if(calc()){
      cout<<0<<endl;
      continue;
    }
    bool flag = false;
    REP(i,d)REP(j,n-1){
      if(flag)break;
      if(mp[i][j]==1)continue;
      if(j!=0 && mp[i][j-1]==1)continue;
      if(j!=n-2 && mp[i][j+1]==1)continue;
      mp[i][j]=1;
      if(calc()){
        cout<<(i+1)<<" "<<(j+1)<<endl;
        flag = true;
      }
      mp[i][j]=0;
    }
    if(!flag) cout<<1<<endl;
  }
  return 0;
}