#include<iostream>
#include<string>

const int COLS = 10;
const int ROWS = 30;

using namespace std;

int RunAmida(int Amida[][COLS+2], int n, int d, int st){
	int ret = st;
	for(int i = 0; i < d; i++){
		for(int j = 1; j < n; j++){
			if(Amida[i][j] == 1){
				if(ret == j){
					ret = j + 1;
					break;
				}
				if(ret == j + 1){
					ret = j;
					break;
				}
			}
		}
	}
	return ret;
}

int main(void){
	while( true ){
		int Amida[ROWS][COLS+2] = {{0,},};
		bool Found = false;
		int n, m, s, d;

		cin >> n;
		if( n == 0 ) break;
		cin >> m >> s >> d;
		for(int i = 0; i < d; i++){
			string s;
			
			cin >> s;
			if( cin.eof() ) break;
			for(int j = 0; j < n - 1; j++){
				if( s[j] == '1' ) Amida[i][j+1] = 1;
			}
		}

		/* no additional bar */
		if( s == RunAmida(Amida, n, d, m) ){
			cout << "0\n";
			Found = true;
		}

		/* one additional bar */
		for(int i = 0; i < d && !Found; i++){
			for(int j = 1; j < n && !Found; j++){
				if( Amida[i][j-1] == 0 && Amida[i][j] == 0 && Amida[i][j+1] == 0 ){
					Amida[i][j] = 1;
					if( s == RunAmida(Amida, n, d, m) ){
						cout << i + 1 << " " << j << endl;
						Found = true;
						break;
					}else Amida[i][j] = 0;
				}
			}
		}

		if( !Found ) cout << "1\n";

	}
	return 0;
}