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

int n, m, p, d;
vector<string> ls;

bool check() {
    int c = m;
    for (int i = 0; i < d; i++) {
        if (ls[i][c] == '1') {
            c++;
        } else if (0 <= c-1 && ls[i][c-1] == '1') {
            c--;
        }
    }
    return c == p;
}

int main() {
    while (cin >> n, n != 0) {
        cin >> m >> p >> d;
        m--, p--;
        ls.clear();
        for (int i = 0; i < d; i++) {
            string s;
            cin >> s;
            ls.push_back(s);
        }

        if (check()) {
            cout << 0 << endl;
            continue;
        }

        int y, x;
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < n-1; j++) {
                if (ls[i][j] == '0' && (
                        (n == 2) ||
                        (j == 0 && ls[i][j+1] == '0') ||
                        (j == n-2 && ls[i][j-1] == '0') ||
                        (ls[i][j-1] == '0' && ls[i][j+1] == '0'))) {
                    ls[i][j] = '1';
                    if (check()) {
                        y = i+1;
                        x = j+1;
                        goto found;
                    }
                    ls[i][j] = '0';
                }
            }
        }
        cout << 1 << endl;
        continue;
found:
        cout << y << ' ' << x << endl;
        continue;
    }
    return 0;
}