#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

bool ok(vector<string>& m, int st, int at){
	int use[11]={0};
	use[st-1]=1;
	
	rep(i,m.size()){
		rep(j,m[i].size()){
			if(m[i][j]=='1')swap(use[j],use[j+1]);
		}
	}
	if(use[at-1]==1)return true;
	return false;
}

int main(){
	int n,m,p,d;
	while(cin>>n,n){
		cin>>m>>p>>d;
		
		vector<string> board(d);
		rep(i,d){
			cin>>board[i];
		}
		
		if(ok(board, m, p))puts("0");
		else{
			rep(i,d){
				rep(j,board[i].size()){
					if(board[i][j]=='0' && (j==0 || board[i][j-1]=='0') && (j==board[i].size()-1 || board[i][j+1]=='0')){
						board[i][j]='1';
						if(ok(board, m, p)){
							printf("%d %d\n",i+1,j+1);
							goto A;
						}
						board[i][j]='0';
					}
				}
			}
			puts("1");
		}
		A:;
	}
}