#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<int,int> P;
typedef complex<double> CP;
typedef long long ll;


int sti[40][10];
int n,m,h,d;
char t;
int hor[40][11];
vector <P> vec;

void swap(int a,int b,int c){
	int t;
	t=sti[c][a];
	sti[c][a]=sti[c][b];
	sti[c][b]=t;
	return;
}

int main(){
	while(cin>>n,n){
		cin>>m>>h>>d;
		rep(i,n){
			sti[0][i]=i;
		}
		rep(i,d){
			rep(j,n){
				sti[i+1][j]=sti[i][j];
			}
			
			rep(j,n-1){
				cin>>t;
				hor[i+1][j]=t-'0';
				if(t-'0'==1){
					swap(j,j+1,i+1);
				}
			}
		}
		bool f=false;
		rep(i,n){
			if(sti[d][i]==m-1&&i==h-1){
				cout<<0<<endl;
				f=true;
			}
		}
		
		rep(i,d){
			rep(j,n-1){
				if(j==0){
					if(hor[i+1][j]==0&&hor[i+1][j+1]==0){
						vec.PB(P(i+1,j));
					}
				}
				else if(j==n-2){
					if(hor[i+1][j-1]==0&&hor[i+1][j]==0){
						vec.PB(P(i+1,j));
					}
				}
				else if(hor[i+1][j-1]==0&&hor[i+1][j]==0&&hor[i+1][j+1]==0){
					vec.PB(P(i+1,j));
				}
			}
		}
		/*
		rep(i,d+1){
			rep(j,n){
				cout<<sti[i][j]<<" ";
			}
			cout<<endl;
		}
		cout<<endl;
		*/
		//cout<<sti[d][h-1]<<" "<<m-1<<endl;
		rep(i,vec.size()){
			int a=vec[i].F,b=vec[i].S;
			//cout<<a<<" "<<b<<"    "<<sti[a][b]<<" "<<sti[a][b+1]<<endl;
			if(sti[a][b+1]==sti[d][h-1]&&sti[a][b]==m-1||sti[a][b]==sti[d][h-1]&&sti[a][b+1]==m-1){
				cout<<a<<" "<<b+1<<endl;
				f=true;
				break;
			}
		}
		if(!f) cout<<1<<endl;
		vec.clear();
		//cout<<endl;
	}
	return 0;
}