#include <iostream>
#include <string>
#include <cstring>
#define MAX_N 10
#define MAX_D 30

using namespace std;

int n, m, g, d, ans1, ans2;
string mp[MAX_D];


int dfs(int nl,int dl){
	if(d == dl){
		return nl;
	}
	if(0 < nl && mp[dl][nl - 1] == '1'){
		return dfs(nl - 1,dl + 1);
	}else if(nl < n - 1 && mp[dl][nl] == '1'){
		return dfs(nl + 1,dl + 1);
	}else{
		return dfs(nl,dl + 1); // そのまま通り抜ける場合
	}
}
int main(void){
	while(true){
		cin >> n ;
		if(n == 0){
			break;
		}
		cin >> m >> g >> d;
		m--; g--;
		cin.get();
		for(int i = 0;i < d;i++){
			getline(cin,mp[i]);
		}
		ans1 = -1, ans2 = -1;
		if(dfs(m,0) == g){
			cout << 0 << endl;
		}else{
			for(int i = 0;i < d;i++){
				for(int j = 0;j < n - 1;j++){
					if(mp[i][j] == '0' && (j == 0 || (0 < j - 1 && mp[i][j - 1] == '0')) && (j == n - 2 || (j + 1 < n - 1 && mp[i][j + 1] == '0'))){
						mp[i][j] = '1';
						if(dfs(m,0) == g && ((ans1 == -1 && ans2 == -1) || ans1 > i + 1)){
							ans1 = i + 1;
							ans2 = j + 1;
						}
						mp[i][j] = '0';
					}
				}
			}
			if(ans1 != -1){
				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;
}