#include<iostream>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
const int MAXD = 30;
const int MAXN = 10;
int n, m, hit, d;
bool ladder[MAXD][MAXN-1];
bool tmp[MAXD][MAXN-1];
bool amida(void){
    int x = m-1;
    REP(i,d){
        if     (x==0   && tmp[i][x])   x=x+1;
        else if(x==n-1 && tmp[i][x-1]) x=x-1;
        else if(tmp[i][x])   x=x+1;
        else if(tmp[i][x-1]) x=x-1;
    }
    return (x==(hit-1));
}
void solve(void)
{   //with nothing
    REP(i,d) REP(j,n-1) tmp[i][j]=ladder[i][j];
    if(amida()){
        cout << 0 << endl;
        return;
    }
    //with one bar
    REP(i,d){ REP(j,n-1){
        if(ladder[i][j]) continue;
        REP(k,d) REP(l,n-1) tmp[k][l]=ladder[k][l];
        tmp[i][j] = true; 
        if(amida()){
            cout << (i+1) << " " << (j+1) << endl;
            return;
        }
    }}
    //cannnot
    cout << 1 << endl;
}
int main(void)
{
    while(true){
        cin>>n;
        if(!n) break;
        cin>>m>>hit>>d;
        REP(i,d){
            string s;
            cin>>s;
            REP(j,n-1) ladder[i][j]=(s[j]=='1')?true:false;
        }
        solve();
    }
    return 0;
}