#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>

//AOJ0069
#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){
int n,hi,at,d;
int my[12][32]={-1};
string ws,am[32];
	
	while(cin >> n){
		if(n==0) break;
		cin >> hi >> at >> d;
		rep(i,d){
			cin >> ws;
//			if(ws == "0" ) break;
			am[i+1] = "0" + ws + "0";
		}
		
		rep2(x,1,n+1){
			my[x][0]=x;
			rep2(i,1,d+2){
				int z = my[x][i-1];
				if(am[i][z-1]=='1') my[x][i] = z -1;
				else if(am[i][z]=='1') my[x][i] = z +1;
				else my[x][i] = z;
			}
		}
		
		int svat=-1;
		rep(i,n+2) if(my[i][d] == at){
				svat = i ; break; 
		}

//	printf("ss:%d %d %d\n",svat,n, at);
		if(svat == hi){
			cout << 0 << endl;
		}else{
			int ngsw=0;
			rep2(i,1,d+1){
				if(abs(my[svat][i] - my[hi][i] )== 1 ){
					int smn = min(my[svat][i] , my[hi][i] );
					if( am[i][smn-1] != '1' && am[i][smn +1] != '1'
						&& am[i][smn] != '1' ){
						cout << i << " " << smn << endl;
						ngsw=1;
						break;
					}
				}
			}
			if(ngsw==0) cout << 1 << endl;
		}
//			rep(x,n+1){rep(i,d+2) printf("%d:%d, ",i,my[x][i] ); printf("\n");}
	}
	return 0;
	
}