#include<iostream>
using namespace std;
int a, b, c, d, x[40][12], y[40][12];
int amida(int s) {
	for (int i = 1; i <= d; i++) {
		if (y[i][s] == 1)s++;
		else if (y[i][s - 1] == 1)s--;
	}
	return s;
}
int main() {
	while (true) {
		cin >> a; if (a == 0)break;
		cin >> b >> c >> d;
		for (int i = 0; i < 40; i++) {
			for (int j = 0; j < 12; j++) { x[i][j] = 0; y[i][j] = 0; }
		}
		for (int i = 1; i <= d; i++) {
			for (int j = 1; j <= a - 1; j++) {
				char f; cin >> f; x[i][j] = (int)(f - '0');
			}
		}
		int maxn = 100000, maxid = 0;
		for (int i = 1; i <= d; i++) {
			for (int j = 1; j <= a; j++) {
				for (int k = 0; k < 40; k++) {
					for (int l = 0; l < 12; l++)y[k][l] = 0;
				}
				for (int k = 1; k <= d; k++) {
					for (int l = 1; l <= a; l++) {
						y[k][l] = x[k][l];
					}
				}
				y[i][j] = 1;
				if (y[i][j - 1] == 1)continue;
				if (y[i][j + 1] == 1)continue;
				int P = amida(b);
				if (c == P) {
					if (x[i][j] == 1)maxn = 0;
					else if (maxn == 100000) { maxn = i; maxid = j; }
				}
			}
		}
		if (maxn == 0)cout << "0" << endl;
		if (maxn == 100000)cout << "1" << endl;
		if (maxn >= 1 && maxn <= 99999)cout << maxn << ' ' << maxid << endl;
	}
	return 0;
}