#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int n,d;
int a[10]={0,1,2,3,4,5,6,7,8,9};
char str[50][20];
void check();
int main(){
    int m,s;
    for(;;){
        cin>>n;
        if(n==0)exit(0);
        cin>>m>>s>>d;
        for(int i=1;i<=d;i++)cin>>str[i];
        check();
        if(a[s]==m)cout<<0<<endl;
        else {
            for(int i=1;i<=d;i++){
                for(int j=0;j<n;j++){
                    for(int k=0;k<10;k++)a[k]=k;
                    if((j==n-2&&str[i][j]!='1'&&str[i][j-1]!='1')||
                        (j==0&&str[i][j]!='1'&&str[i][j+1]!='1')||
                        (j!=0&&j!=n-2&&str[i][j]!='1'&&str[i][j+1]!='1'&&str[i][j-1]!='1')){
                        str[i][j]='1';
                        check();
                        if(a[s]==m){
                            cout<<i<<" "<<j+1<<endl;
                            goto end;
                        }
                        str[i][j]='0';
                    }
                }
            }
            cout<<1<<endl;
        }
        end:;
        for(int i=0;i<10;i++)a[i]=i;
        for(int i=0;i<50;i++)for(int j=0;j<20;j++)str[i][j]=0;
    }
    return 0;
}
void check(){
    for(int i=1;i<=d;i++){
        for(int j=1;j<n;j++){
            if(str[i][j-1]=='1')swap(a[j],a[j+1]);
        }
    }
    return;
}