#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// row, column, left or right
bool movearray[40][15][2];
int n, m, goal, d;

bool solve(int r, int c, int prev) {
    if(r == d) {
        if(c == goal) return true;
        else return false;
    }
    else {
        if(movearray[r][c][0] && prev != 1) return solve(r, c-1, 0);
        else if(movearray[r][c][1] && prev != 0) return solve(r, c+1, 1);
        else return solve(r+1, c, -1);
    }
    return false;
}

int main() {
    while(cin >> n, n) {
        cin >> m >> goal >> d; m--; goal--;
        memset(movearray, false, sizeof(movearray));
        int inp;
        int board[40][15] = {};
        rep(i,0,d) rep(j,0,n-1) {
            scanf("%1d", &inp);
            if(inp == 1) {
                movearray[i][j  ][1] = true;
                movearray[i][j+1][0] = true;
                board[i][j] = inp;
            }
        }

        if(solve(0, m, -1)) cout << 0 << endl;
        else {
            bool ans = false;
            rep(i,0,d) rep(j,0,n-1) {
                if(ans) continue;
                bool ok = true;
                if(board[i][j]) ok = false;
                if(j != 0   && board[i][j-1]) ok = false;
                if(j != n-2 && board[i][j+1]) ok = false;
                if(!ok) continue;

                movearray[i][j  ][1] = true;
                movearray[i][j+1][0] = true;
                if(solve(0, m, -1)) {
                    printf("%d %d\n", i+1, j+1);
                    ans = true;
                }
                movearray[i][j  ][1] = false;
                movearray[i][j+1][0] = false;
            }
            if(!ans) cout << 1 << endl;
        }
    }
    return 0;
}