#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n,m,d,a;
  while(cin>>n){
    if(n==0) break;
    cin>>m>>a>>d;
    string sen[31];
    int s[31];
    int g[31];
    s[0] = m;
    g[d] = a;
    REP(i,d){
      cin>>sen[i];
    }
    REP(i,d){
      if(s[i]!=1&&sen[i][s[i]-2]=='1'){
        s[i+1] = s[i] -1;
      }else if(s[i]!=n&&sen[i][s[i]-1]=='1'){
        s[i+1] = s[i] +1;
      }else{
        s[i+1] = s[i];
      }
      if(g[d-i]!=1&&sen[d-i-1][g[d-i]-2]=='1'){
        g[d-i-1] = g[d-i] -1;
      }else if(g[d-i]!=n&&sen[d-i-1][g[d-i]-1]=='1'){
        g[d-i-1] = g[d-i] +1;
      }else{
        g[d-i-1] = g[d-i];
      }
    }
    bool f=true;
    int ans[2];
    if(s[d]==g[d]){
     cout<<0<<endl;
    }else{
      FOR(i,1,d+1){
        if(g[i]-s[i]==1){
          if(sen[i-1][s[i]-1]=='0'&&(s[i]==1||sen[i-1][s[i]-2]=='0')
              &&(g[i]==n||sen[i-1][s[i]]=='0')){
            f=false;
            ans[0] = i;
            ans[1] = s[i];
            break;
          }
        }else if(g[i]-s[i]==-1){
            swap(s[i],g[i]);
          if(sen[i-1][s[i]-1]=='0'&&(s[i]==1||sen[i-1][s[i]-2]=='0')
              &&(g[i]==n||sen[i-1][s[i]]=='0')){
            f=false;
            ans[0] = i;
            ans[1] = s[i];
            break;
          }
        }
      }
      if(f) cout<<1<<endl;
      else{
        printf("%d %d\n",ans[0],ans[1]);
      }
    }  
  }
  return 0;
}