#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool ok(vector<string> &v, int m, int goal) {
    int pos = m;
    for (int i=0; i<(int)v.size(); ++i) {
        if (pos < (int)v[i].size() && v[i][pos] == '1') {
            pos ++;
        } else if (0 <= pos - 1 && v[i][pos-1] == '1') {
            pos --;
        }
    }
    return (pos == goal);
}

int main() {
    int n, m, goal, d;
    while (cin >> n, n) {
        cin >> m >> goal >> d;
        -- m; -- goal;
        vector<string> amida(d);
        for (int i=0; i<d; ++i) {
            cin >> amida[i];
        }
        if (ok(amida, m, goal)) {
            cout << 0 << endl;
            continue;
        }
        int y = -1, x;
        for (int i=0; i<d; ++i) {
            for (int j=0; j<n-1; ++j) {
                if (amida[i][j] == '1') continue;
                if (j+1 < n-1 && amida[i][j+1] == '1') continue;
                if (0 <= j-1 && amida[i][j-1] == '1') continue;
                amida[i][j] = '1';
                if (ok(amida, m, goal)) {
                    y = i;
                    x = j;
                    goto end;
                }
                amida[i][j] = '0';
            }
        }end:;
        if (y < 0) {
            cout << 1 << endl;
        } else {
            cout << y+1 << " " << x+1 << endl;
        }
    }
    return 0;
}