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

typedef pair<int,int> P;
typedef queue<P> Q;

int main ()
{
    int N, m, g, D;
    while (cin >> N, N) {
        cin >> m >> g >> D;
        vector<string> v (D+1, "0000000000");
        for (int i = 0; i < D; i++) {
            cin >> v[i];
        }

        int d[D+1][N];
        for (int i = 0; i <= D; i++) for (int j = 0; j < N; j++) d[i][j] = 0;

        int y = m - 1;
        for (int i = 0; i <= D; i++) {
            d[i][y] = 5;
            if (0 < y && v[i][y-1] == '1') {
                y -= 1;
            } else if (y < N - 1 && v[i][y] == '1') {
                y += 1;
            }
        }
        if (g-1 == y) {
            cout << 0 << endl;
            continue;
        }

        y = g - 1;
        for (int i = D; i >= 0; i--) {
            d[i][y] = 6;
            if (0 < y && v[i][y-1] == '1') {
                y -= 1;
            } else if (y < N - 1 && v[i][y] == '1') {
                y += 1;
            }
        }

        for (int i = 0; i <= D; i++) {
            for (int j = 0; j < N; j++) {
                if (0 < j && d[i][j] == 5 && d[i][j-1] == 6) {
                    cout << (i+1) << " " << (j+1) << endl;
                    goto escape;
                }
                if (j < N - 1 && d[i][j] == 5 && d[i][j+1] == 6) {
                    cout << (i+1) << " " << (j+1) << endl;
                    goto escape;
                }
            }
        }

        cout << 1 << endl;
    escape:;
    }
    return 0;
}