#include <iostream>
#include <string>
#include <cstring>
#define MAX_N 10
#define MAX_D 30
#define PAT1 0 // 一本も追加せずに目的地に着ける場合
#define PAT2 2 // 一本追加して目的地に着ける場合
#define PAT3 1 // 一本追加しても目的地に着けない場合

using namespace std;

int n, m, g, d, e[MAX_D][MAX_N][MAX_N], mem[MAX_N][MAX_D], ans1, ans2;

int priority(int a,int b){
	if(a == PAT1 || b == PAT1){
		return PAT1;
	}else if(a == PAT2 || b == PAT2){
		return PAT2;
	}else{
		return PAT3;
	}
}

int dfs(int nl,int dl,bool lf){
	int res = 1;
	if(d == dl){
		if(nl == g){
			if(!lf){
				return PAT1;
			}else{
				return PAT2;
			}
		}else{
			return PAT3;
		}
	}
	if(mem[nl][dl] >= 0){
		return mem[nl][dl];
	}
	if(0 < nl && e[dl][nl][nl - 1] == 1){
		res = priority(res, dfs(nl - 1,dl + 1,lf));
	}else if(nl < n - 1 && e[dl][nl][nl + 1] == 1){
		res = priority(res, dfs(nl + 1,dl + 1,lf));
	}else{
		if(0 < nl && !lf){
			int val = dfs(nl - 1,dl + 1,!lf);
			res = priority(res,val);
			if(val == PAT2 && ((ans1 == -1) || ans1 > dl + 1)){
				ans1 = dl + 1;
				ans2 = nl;
			}
		}
		if(nl < n && !lf){
			int val = dfs(nl + 1,dl + 1,!lf);
			res = priority(res,val);
			if(val == PAT2 && ((ans1 == -1) || ans1 > dl + 1)){
				ans1 = dl + 1;
				ans2 = nl + 1;
			}
		}
		res = priority(res,dfs(nl,dl + 1,lf)); // そのまま通り抜ける場合
	}
	return mem[nl][dl] = res;
}
int main(void){
	cin >> n >> m >> g >> d;
	m--; g--;
	cin.get();
	for(int i = 0;i < d;i++){
		string s;
		getline(cin,s);
		for(int j = 0;j < n - 1;j++){
			e[i][j][j + 1] = s[j] - '0';
			e[i][j + 1][j] = s[j] - '0';
		}
	}
	ans1 = -1, ans2 = -1;
	memset(mem,-1,sizeof(mem));
	int res = dfs(m,0,false);
	if(res == PAT1){
		cout << PAT1 << endl;
	}else if(res == PAT2){
		cout << ans1 << " " << ans2 << endl;
	}else{
		cout << 1 << endl;
	}
/*	for(int i = 0;i < d;i++){
		for(int j = 0;j < n - 1;j++){
			for(int k = 0;k < n - 1;k++){
				cout << j << "->" << k << ":" << e[i][j][k] << endl;
			}
		}
	}*/
	return 0;
}