#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, r, d; vector<string> v;
bool ok(vector<string> w) {
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n - 2; j++) {
			if (w[i][j] == '1' && w[i][j + 1] == '1') return false;
		}
	}
	int pos = m;
	for (int i = 0; i < d; i++) {
		if (pos > 0 && w[i][pos - 1] == '1') pos--;
		else if (pos < n - 1 && w[i][pos] == '1') pos++;
	}
	return (pos == r);
}
int main() {
	while (cin >> n, n) {
		cin >> m >> r >> d; m--; r--; v.resize(d);
		for (int i = 0; i < d; i++) cin >> v[i];
		if (ok(v)) {
			cout << 0 << endl;
			continue;
		}
		bool flag = false;
		for (int i = 0; i < d; i++) {
			if (flag) break;
			for (int j = 0; j < n - 1; j++) {
				if (v[i][j] == '0') {
					v[i][j] = '1';
					if (ok(v)) {
						cout << i + 1 << ' ' << j + 1 << endl;
						flag = true; break;
					}
					v[i][j] = '0';
				}
			}
		}
		if(!flag) cout << 1 << endl;
	}
	return 0;
}