#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;
    else if(j == n-2 && amida[i][j-1] == '0') return true;
    else 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){
        amida.clear();
        cin >> m >> g >> d;
        for(int i=0; i < d; i++){
            string p;
            cin >> p;
            amida.push_back(p);
        }
        pair<int, int> ret = make_pair(0, 0);
        if(check(m) == g){ cout << 0 << endl; continue;}
        bool f = false;
        for(int i=0; i< d; i++){
            for(int j=0; j < n-1; j++){
                if(f) continue;
                if(amida[i][j] == '0' && is(i, j)){
                    amida[i][j] = '1';
                    if(check(m) == g){ret = make_pair(i+1, j+1); f = true;}
                    amida[i][j] = '0';
                }
            }
        }
        if(ret.first != 0) cout << ret.first << " " << ret.second << endl;
        else cout << 1 << endl;
    }
}