#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
bool isGoal(int n, int m, int s, int t, string bar, int c) {
	s--,t--;
	if(c != -1) {
		bar[c] = '1';
	}
	rep(i,m) {
		rep(j,n-1) {
			if(bar[i *(n-1) + j] == '1') {
				if(s == j) s = j + 1;
				else if(s == j + 1) s = j;
			}
		}
	}
	if(s == t) return true;
	return false;
}
int main() {
	int n, m, s, t;
	string str;
	while(cin >> n && n) {
		cin >> s >> t >> m;
		string bar;
		rep(i,m) {
			cin >> str;
			bar += str;
		}
		if(isGoal(n,m,s,t,bar,-1)) {
			cout << 0 << endl;
			continue;
		}
		bool f = 0;
		rep(i,m) {
			rep(j,n-1) {
				if(j==0 && bar[i*(n-1)+1] == '0') {
					if(isGoal(n,m,s,t,bar,i*(n-1))) {
						cout << i+1 << " " << j+1 << endl;
						f = 1;
						break;
					}
				} else if(j == n-2 && bar[i*(n-1)+n-3] == '0') {
					if(isGoal(n,m,s,t,bar,i*(n-1)+n-2)) {
						cout << i+1 << " " << j+1 << endl;
						f = 1;
						break;
					}
				} else if((j != 0 || j != n-2) && bar[i*(n-1)+j-1] == '0' && bar[i*(n-1)+j+1] == '0') {
					if(isGoal(n,m,s,t,bar,i*(n-1)+j)) {
						cout << i+1 << " " << j+1 << endl;
						f = 1;
						break;				
					}
				}
			}
			if(f) break;
		}
		if(!f) cout << 1 << endl;
	}
	return 0;
}