#include <bits/stdc++.h>
#define range(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) range(i,0,n)
using namespace std;

int n,m,a,d;
string bar[33];

bool simuration(){
	int state[10];
	rep(i,10) state[i]=i;
	rep(i,d)rep(j,n-1) if(bar[d-1-i][j]=='1') swap(state[j],state[j+1]);
	return state[m]==a;
}

int main(void){
	while(cin >> n,n){
		cin >> m >> a >> d;
		m--,a--;
		rep(i,d) cin >> bar[i];
		if(simuration()){
			cout << 0 << endl;
			continue;
		}else{
			bool ans=false;
			rep(i,d)rep(j,n-1){
				if(bar[i][j]=='1') continue;
				if(0<=j-1&&bar[i][j-1]=='1') continue;
				if(j+2<n&&bar[i][j+1]=='1') continue;
				bar[i][j]='1';
				if(simuration()){
					cout << (i+1) << " " << (j+1) << endl;
					ans=true;
				}
				bar[i][j]='0';
				if(ans) i=d,j=n-1;
			}
			if(!ans) cout << 1 << endl;
		}
	}
	return 0;
}