#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<functional>
#include <memory.h>



using namespace std;
int row_max,start,goal,col_max;

int amida_test(int yoko[30][12]){
    int now=start;
    for(int i=0; i<col_max; i++){
        if(yoko[i][now]==1)now++;
        else if(yoko[i][now-1]==1)now--;
    }
    return now;
}

int amida_plus(int yoko[30][12]){
    if(amida_test(yoko)==goal){
        cout<<0<<endl;
        return 1;
    }
    for(int i=0;i<col_max; i++){
        for(int j=1; j<row_max; j++){
            if(yoko[i][j+1]==0&&yoko[i][j]==0&&yoko[i][j-1]==0){
                int temp_yoko[30][12]={0};
                memcpy(temp_yoko, yoko, sizeof(int)*30*12);
                temp_yoko[i][j]=1;
                int ret = amida_test(temp_yoko);
                if(ret == goal){
                    cout<<i+1<<" "<<j<<endl;
                    return 1;
                }
            }
        }
    }
    cout<<1<<endl;
    return 0;
}




int main(){
    
    while(cin>>row_max){
        if(row_max==0)break;
        cin>>start>>goal>>col_max;
        

        
        
        int yoko[30][12]={0};

        
        for(int i=0; i<col_max; i++){
            string temp;
            cin>>temp;
            for(int j=1; j<row_max; j++){
                yoko[i][j]=temp[j-1]-'0';
            }
        }
        /*
        cout<<endl;
        for(int i=0; i<30; i++){
            for(int j=0; j<12; j++){
                cout<<"|";
                if(yoko[i][j]==1){
                    cout<<"-";
                }else{
                    cout<<" ";
                }
            }
            cout<<endl;
        }
         */
        
        amida_plus(yoko);


    }
    
    
    
    /*
     5
     2
     3
     9
     1010
     1001
     0100
     1001
     0010
     1000
     0100
     0101
     1010
     
     */
}