#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N, M, A, D;
int G[30][10];

bool can(int phase, int index){
    // printf("%d, %d, %d\n", phase, index, G[phase][index]);
    if(phase == D){return index == A;}

    if(G[phase][index] != -1){
        return can(phase+1, G[phase][index]);
    }
    return can(phase+1, index);
}

int main(){
    while(std::cin >> N >> M >> A >> D, N != 0){
        --M; --A;

        REP(i, 30){
            REP(j, 10){
                G[i][j] = -1;
            }
        }

        REP(i, D){
            REP(j, N-1){
                char f;
                std::cin >> f;
                if(f == '1'){G[i][j] = j+1; G[i][j+1] = j;}
            }
        }

        if(can(0, M)){puts("0");}
        else{
            P res = mp(-1, -1);
            REP(i, D){
                REP(j, N-1){
                    if(G[i][j] == -1 && (j+1 >= N || G[i][j+1] == -1)){
                        G[i][j] = j+1;
                        G[i][j+1] = j;
                        if(res.first == -1 && can(0, M)){res = mp(i+1, j+1);}
                        G[i][j] = -1;
                        G[i][j+1] = -1;
                    }
                }
            }
        

            if(res.first != -1){
                printf("%d %d\n", res.first, res.second);
            }else{
                puts("1");
            }
        }
    }
}