#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

using namespace std;

int n,m,star,d;

bool C(vector<string> &s){
	int cu = m;
	for (int i = 0; i < d; i++){
	if(cu != 0)
		if(s[i][cu - 1] == '1'){
			cu--; continue;
		}
	if(cu != n - 1)
		if(s[i][cu] == '1'){
			cu++; continue;
		}
	}

	return cu == star;
}

void solve()
{
	cin>>m>>star>>d;
	m--; star--;
	vector<string> s(d);
	for (int i = 0; i < d; i++){
		cin>>s[i];
	}

	if(C(s)){
		puts("0");
		return;
	}
	for (int i = 0; i < d; i++){
		for (int j = 0; j < n - 1; j++){
			if(j != 0)
				if(s[i][j-1] == '1') continue;
			if(s[i][j] == '1') continue;
			if(j != n - 2)
				if(s[i][j+1] == '1') continue;
			s[i][j] = '1';
			if(C(s)){
				printf("%d %d\n",i + 1,j + 1);
				return ;
			}
			s[i][j] = '0';
		}
	}

	puts("1");
}

int main(){
	while(cin>>n,n){
		solve();
	}
    return 0;
}