#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>

using namespace std;

int debug = 0;

int main(void){
	int n,start,goal,d;
	
	while(1){
		bool clear = false;
		
		cin >> n;
		if(n==0) break;
		cin >> start;
		cin >> goal;
		cin >> d;
		
		bool way[d+1][n+1]; //way[i][j] := i-th(1origin) horizontal line's j-th(1origin) vertical line
		
		cin.ignore(); //for CR+LF
		
		memset(way,false,sizeof(way));
		for(int i=1;i<=d;i++){
			string str;
			char tmp;
			int j=1;
			getline(cin,str);
			istringstream iss(str);
			
			while(iss >> tmp){
				if(tmp == '1'){
					way[i][j] = true;
				}else{
					way[i][j] = false;
				}
				j++;
			}
		}
		
		if(debug){
			for(int i=1;i<=d;i++){
				for(int j=1;j<=n-1;j++){
					cout << way[i][j];
				}
				cout << endl;
			}
		}
		
		int place = start;
		for(int k=1;k<=d;k++){
			if(way[k][place-1] == true){
				place--;
			}else if(way[k][place] == true){
				place++;
			}
		}
		if(place == goal){
			cout << 0 <<endl;
			continue;
		}
		
		for(int i=1;i<=d && !clear;i++){
			for(int j=1;j<=n-1 && !clear;j++){
				bool isok = false;
				bool iscand = false;
				if(way[i][j] == false){
					if(j==1){
						if(way[i][j+1] == false){
							iscand = true;
						}
					}else if(j == n-1){
						if(way[i][j-1] == false){
							iscand = true;
						}
					}else{
						if(way[i][j-1] == false && way[i][j+1] == false){
							iscand = true;
						}
					}
					if(iscand){ //try
						if(debug) cout << "trying " << i << " " << j << endl;
						int place = start;
						way[i][j] = true;
						for(int k=1;k<=d;k++){
							if(way[k][place-1] == true){
								place--;
							}else if(way[k][place] == true){
								place++;
							}
							if(debug) cout <<  k <<":place " << place << endl;
						}
						if(place == goal){
							cout << i << " " << j << endl;
							clear = true;
						}
						way[i][j] = false;
					}
				}
			}
		}
		if(!clear){
			cout << 1 << endl;
		}
	}
}