#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

int n, m, e, d;
vector<string> s;

bool calc(){
	int y = 0, x = m;
	for(; y < d; y++){
		if(s[y][x]=='1'){
			x++;
		}
		else if(s[y][x-1] == '1'){
			x--;
		}
	}
	return x == e;
}

bool calc(int y, int x){
	bool f =false;
	if((x==0||s[y][x-1]=='0')&&(x+1==n-1||s[y][x+1]=='0')){
		s[y][x]='1'; f= true;
	}
	if(calc()) return true;
	if(f) s[y][x]='0';
	return false;
}

int main(){
	while(cin>>n && n){
		cin>>m>>e>>d;
		m--; e--;
		s = vector<string>(d);
		rep(i, d) cin>>s[i];
		if(calc()){
			cout<<"0"<<endl; continue;
		}
		bool f = false;
		rep(i, d){
			rep(j, n-1){
				if(s[i][j]!='1' && calc(i, j)){
					cout<<i+1<<" "<<j+1<<endl;
					f=true;
					break;
				}
			}
			if(f) break;
		}
		if(!f) cout<<"1"<<endl;
	}
	
}