#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define UNWORDS(vec, str) for(int i = 0; i < (vec).size(); ++i) cout << (i ? str : "") << (vec)[i]
#define UNLINES(vec) for(int i = 0; i < (vec).size(); ++i) cout << (vec)[i] << endl
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;
vector< vector< char > > amida;
int n, m, t, d;

int check(){
	int cur = m;
	
	REP(i, d){
		if(amida[i][cur - 1] == 1){
			--cur;
		}else if(amida[i][cur] == 1){
			++cur;
		}
	}
	
	return cur == t;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(cin >> n, n){
		cin >> m >> t >> d;
		
		amida.CLR();
		
		amida.RS(d);
		REP(i, d){
			amida[i].RS(n + 1);
			
			FORE(j, 1, n - 1){
				cin >> amida[i][j];
				amida[i][j] -= '0';
			}
		}
		
		if(check()){
			cout << 0 << endl;
		}else{
			
			bool suc = false;
			REP(i, d){
				FORE(j, 1, n - 1){
					
					if(amida[i][j] == 0 && amida[i][j - 1] == 0 && amida[i][j + 1] == 0){
						amida[i][j] = 1;
						
						if(check()){
							cout << i + 1 << " " << j << endl;
							suc = true;
							break;
						}
						
						amida[i][j] = 0;
					}
				}
			}
			
			if(!suc) cout << 0 << endl;
		}
	}
	
	return 0;
}