#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int n,m,hit,d;

bool solve(int a[31][10]){
    vector<int> x;
    rep(i,n){
        if(i==m-1)x.pb(1);
        else x.pb(0);
    }
    rep(i,d){
        rep(j,n-1){
            if(a[i][j]==1){
                swap(x[j],x[j+1]);
            }
        }
    }
    if(x[hit-1])return true;
    else return false;
}


int main(){
    while(cin>>n){
        if(n==0)break;
        cin>>m>>hit>>d;
        char data[31][10];
        rep(i,d){
            rep(j,n-1){
                cin>>data[i][j];
            }
        }
        int a[31][10];
        rep(i,d)rep(j,n-1)a[i][j]=data[i][j]-'0';
        
        if(solve(a)){cout<<"0"<<endl;goto next;}
        
        rep(i,d){
            rep(j,n-1){
                if(a[i][j]!=0)continue;
                if( n==1 || (j==0 && a[i][j+1]==0) ){
                    a[i][j]=1;
                    if(solve(a)){cout<<i+1<<" "<<j+1<<endl;goto next;}
                    a[i][j]=0;
                }
                else if( j==n-1 && a[i][j-1]==0 ){
                    a[i][j]=1;
                    if(solve(a)){cout<<i+1<<" "<<j+1<<endl;goto next;}
                    a[i][j]=0;
                }
                else if( j!=0 && j!=n-1 && a[i][j+1]==0 && a[i][j-1]==0 ){
                    a[i][j]=1;
                    if(solve(a)){cout<<i+1<<" "<<j+1<<endl;goto next;}
                    a[i][j]=0;
                }
            }
        }
        cout<<"1"<<endl;
        next:;
    }
}