#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#define z 30
using namespace std;
bool amida(int n,int m,int a,int d,int b[z][z]){
	int t = m;
	for(int i=0;i<d;i++){
		if(t==1 and b[0][i]==1) t++;
		else if(t==n and b[n-2][i]==1) t--;
		else if(b[t-2][i]==1) t--;
		else if(b[t-1][i]==1) t++;
	}
	if(t==a) return true;
	else return false;
}
int main(){
	int n,m,a,d;
	while(cin >> n >> m >> a >> d){
		int b[z][z];
		for(int i=0;i<d;i++) for(int j=0;j<n-1;j++) scanf("%1d",&b[j][i]);
		if(amida(n,m,a,d,b)){
			cout << 0 << endl;
			continue;
		}
		bool out = false;
		for(int y=0;y<d;y++){
			if(out) break;
			for(int x=0;x<n-1;x++){
				if(out) break;
				if(b[x][y]==1) continue;
				if(x==0 and b[1][y]==1) continue;
				if(x==n-2 and b[n-3][y]==1) continue;
				int c[z][z];
				for(int i=0;i<d;i++) for(int j=0;j<n-1;j++) c[j][i] = b[j][i];
				c[x][y] = 1;
				if(amida(n,m,a,d,c)){
					cout << y+1 << " " << x+1 << endl;
					out = true;
				}
			}
		}
		if(not out) cout << 1 << endl;
	}
}