#include <bits/stdc++.h>

using namespace std;

string amida[31];
int n, start, goal, d;

bool check(){
    int c = start;
    for(int i=0; i < d; i++){
        if(c < n-1 && amida[i][c] == '1') c++;
        else if(0 < c && amida[i][c-1] == '1') c--;
    }
    return c == goal;
}

bool is(int i, int j){
    if(amida[i][j] != '0') return false;
    if(0 < j && amida[i][j-1] == '1') return false;
    else if(amida[i][j+1] == '1') return false;
    return true;
}

int main(){
    while(cin >> n, n){
        cin >> start >> goal >> d;
        start--; goal--;
        for(int i=0; i < d; i++) cin >> amida[i];
        if(check()){cout << 0 << endl; continue;}
        bool f = false;
        for(int i=0; i< d; i++){
            for(int j=0; j < n-1; j++){
                if(!f && is(i, j)){
                    amida[i][j] = '1';
                    if(check()){cout << i+1 << " " << j+1 << endl; f = true;}
                    amida[i][j] = '0';
                }
            }
        }
        if(!f) cout << 1 << endl;
    }
}