#include <iostream>
#include <vector>
using namespace std;

int main(){
    int n, m, s, d;
    string amida[30];
    cin >> n >> m >> s >> d;
    for(int i = 0; i < d; i++){
        cin >> amida[i];
    }
    vector< vector<int> > cur(31, vector<int>(5,0));
    cur[0][0] = 1;
    cur[0][1] = 2;
    cur[0][2] = 3;
    cur[0][3] = 4;
    cur[0][4] = 5;
    for(int i = 0; i < d; i++){
        vector<int> tmp(cur[i]);
        for(int j = 0; j < 4; j++){
            if( amida[i][j] == '1' ){
                swap( tmp[j], tmp[j+1] );
            }
        }
        cur[i+1] = tmp;
    }
    if( cur[d][s-1] == m ){
        cout << 0 << endl;
    }else{
        int a = cur[d][s-1];
        bool ok = false;
        for(int i = 0; i < d && !ok; i++){
            for(int j = 0; j < 4 && !ok; j++){
                if( amida[i][j] == '0' &&
                    ( !j || amida[i][j-1] == '0' ) &&
                    ( j==3 || amida[i][j+1] == '0') &&
                    ((cur[i][j] == m && cur[i][j+1] == a ||
                      cur[i][j] == a && cur[i][j+1] == m )) ){
                    cout << i+1 << ' ' << j+1 << endl;
                    ok = true;
                }
            }
        }
        if( !ok ) cout << 1 << endl;
    }
    cin >> n;
    return 0;
}