#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

bool solve(vector<string>& line, int a, int b)
{
    int n = line[0].size() + 1;
    int m = line.size();

    for(int i=0; i<m; ++i){
        if(a > 0 && line[i][a-1] == '1'){
            -- a;
        }else if(a < n-1 && line[i][a] == '1'){
            ++ a;
        }
    }

    return a == b;
}

int main()
{
    for(;;){
        int n, a, b, m;
        cin >> n >> a >> b >> m;
        if(n == 0)
            return 0;
        -- a;
        -- b;

        vector<string> line(m);
        for(int i=0; i<m; ++i)
            cin >> line[i];

        if(solve(line, a, b)){
            cout << 0 << endl;
            continue;
        }

        bool ok = false;
        for(int i=0; i<m; ++i){
            for(int j=0; j<n-1; ++j){
                if(!ok && (j == 0 || line[i][j-1] == '0') && line[i][j] == '0' && (j == n-2 && line[i][j-1] == '0')){
                    line[i][j] = '1';
                    if(solve(line, a, b)){
                        cout << (i+1) << ' ' << (j+1) << endl;
                        ok = true;
                    }
                    line[i][j] = '0';
                }
            }
        }
        if(!ok)
            cout << 1 << endl;
    }
}