#include <bits/stdc++.h>

using namespace std;

vector<string> amida;

int n;

int check(int d){
    for(int i=0; i < amida.size(); i++){
        if(d != n && amida[i][d-1] == '1') d++;
        else if(d != 1 && amida[i][d-2] == '1') d--;
    }
    return d;
}

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

int main(){
    int m, g, d;
    while(cin >> n, n){
        cin >> m >> g >> d;
        for(int i=0; i < d; i++){
            string p;
            cin >> p;
            amida.push_back(p);
        }
        pair<int, int> ret; ret.first = 0;
        if(check(m) == g) cout << 0 << endl;
        else {
            for(int i=0; i< amida.size(); i++){
                for(int j=0; j < n-1; j++){
                    if(amida[i][j] == '0'){
                        if(is(i, j)){
                            amida[i][j] = '1';
                            if(check(m) == g)ret = make_pair(i+1, j+1);
                            amida[i][j] = '0';
                        }
                    }
                    if(ret.first != 0) break;
                }
                if(ret.first != 0) break;
            }
            if(ret.first != 0) cout << ret.first << " " << ret.second << endl;
            else cout << 1 << endl;
        }
        amida.clear();
    }
}