#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef vector <string> VS;

const int size = 31;
VS lines( size );
bool O[size][10];
int n, m, a, d;

bool dfs( int t, int k ) {
    if ( t == d + 1 ) {
        return k == a;
    }
    if ( k == 1 ) {
        if ( O[t][k] ) return dfs( t + 1, k + 1 );
    } else if ( k == n ) {
        if ( O[t][k-1] ) return dfs( t + 1, k - 1 );
    } else {
        if ( O[t][k] ) return dfs( t + 1, k + 1 );
        if ( O[t][k-1] ) return dfs( t + 1, k - 1 );
    }
    return dfs( t + 1, k );
}

bool check() {
    return dfs( 0, m );
}

void solve() {
    for ( int i = 0; i < d; ++ i ) {
        for ( int j = 0; j < n; ++ j ) {
            if ( O[i][j] ) continue;
            if ( ( j-1 >= 0 && O[i][j-1] ) || ( j+1 < n-1 && O[i][j+1] ) ) continue;
            O[i][j] = true;
            if ( check() ) {
                cout << i << " " << j << endl;
                return;
            }
            O[i][j] = false;
        }
    }
    cout << 1 << endl;
}

int main() {
    while ( cin >> n && n ) {
        cin >> m >> a >> d;
        for ( int i = 0; i < d; ++ i ) {
            cin >> lines[i];
        }
        for ( int i = 0; i < d+2; ++ i ) {
            for ( int j = 0; j < n+2; j++ ) {
                O[i][j] = false;
            }
        }
        for ( int i = 0; i < d; ++ i ) {
            for ( int j = 0; j < n - 1; ++ j ) {
                O[i+1][j+1] = ( lines[i][j] == '1' );
            }
        }
        if ( check() ) {
            cout << 0 << endl;
        } else {
            solve();
        }
    }
    return 0;
}