#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

void charAnd(char *a, char *b, char *r, int n){
	for(int i=0; i<n; ++i){
		if(a[i]=='1' && b[i]=='1'){
			r[i]='1';
		}else{
			r[i]='0';
		}
	}
}
void charOr(char *a, char *b, char *r, int n){
	for(int i=0; i<n; ++i){
		if(a[i]=='1' || b[i]=='1'){
			r[i]='1';
		}else{
			r[i]='0';
		}
	}
}


//0069
int main(){
	int n,pos,p_pos,stages;
	int zero;

	cin >> n;
	cin >> pos;
	--pos;
	cin >> p_pos;
	--p_pos;
	cin >> stages;

	char own[30][10];
	memset(own, '0',sizeof(own));
	char prize[30][10];
	memset(prize, '0',sizeof(prize));
	char net[30][10];
	memset(net, '0',sizeof(net));

	for(int i=0; i<stages; ++i){
		cin >> net[i];

		own[i][n]='\0';
		if(pos==0){
			if(net[i][pos]=='1'){
				own[i][pos+1]='1';
				++pos;
			}else{
				own[i][p_pos]='1';
			}
		}else{
			if(net[i][pos-1]=='1'){
				own[i][pos-1]='1';
				--pos;
			}else if(net[i][pos]=='1'){
				own[i][pos+1]='1';
				++pos;
			}else{
				own[i][pos]='1';
			}
		}
		
	}
	cin >> zero;
	if(zero!=0) cout << "error: input invalid" << endl;

	for(int i=stages-1; i>=0; --i){
		prize[i][n]='\0';

		if(p_pos==0){
			if(net[i][p_pos]=='1'){
				prize[i][p_pos]='1';
				++p_pos;
			}else{
				prize[i][p_pos]='1';
			}
		}else{
			if(net[i][p_pos-1]=='1'){
				prize[i][p_pos]='1';
				--p_pos;
				//cout << "error" << endl;
			}else if(net[i][p_pos]=='1'){
				prize[i][p_pos]='1';
				++p_pos;
			}else{
				prize[i][p_pos]='1';
			}
		}

	}

	//for(int i=0; i<stages; ++i){
	//	printf("%s %s %s\n", net[i], own[i], prize[i]);
	//}

	//経路が同一かをチェック
	bool isMatch = true;
	for(int i=0; i<stages; ++i){
		int r = strcmp(own[i], prize[i]);
		if(r!=0){
			isMatch = false;
		}
	}
	if(isMatch){
		cout << "0" << endl;
		return 0;
	}

	//線の追加で当たりにたどれるか
	int stage, line;
	char cmp[9][2][11] = {
		{"1100000000","1100000000"},
		{"0110000000","1110000000"},
		{"0011000000","0111000000"},
		{"0001100000","0011100000"},
		{"0000110000","0001110000"},
		{"0000011000","0000111000"},
		{"0000001100","0000011100"},
		{"0000000110","0000001110"},
		{"0000000011","0000000110"},
	};
	for(stage=0; stage<stages; ++stage){
		char lineState[11] = "0000000000";
		charOr(own[stage], prize[stage], lineState, n);
		for(line=0; line<n-1; ++line){
			//経路が隣あえば線の追加で当たりに到達する
			int r1 = strcmp(cmp[line][0], lineState);
			if(r1==0){
				//線を追加しようとしている両隣に線がないか確認
				char prevAndNextLineState[11] = "0000000000";
				charAnd(net[stage], cmp[line][1], prevAndNextLineState, n-1);
				int r2 = strcmp("0000000000", prevAndNextLineState);

				if(r2==0){
					cout << stage+1 << " " << line+1 << endl;
					return 0;
				}
			}
		}
	}

	cout << "1" << endl;
	return 0;
}