#include <iostream>
#include <vector>
#include <string>
using namespace std;

int n, m, x, d;
vector<string> field;

bool solve() {
	int num[n];
	for (int i = 0; i < n; i++) num[i] = i + 1;
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n - 1; j++) {
			if (field[i][j] == '1') {
				swap(num[j], num[j + 1]);
			}
		}
	}
	return (num[x - 1] == m);
}

int main() {
	while (cin >> n, n) {
		cin >> m >> x >> d;
		field.clear();
		for (int i = 0; i < d; i++) {
			string line;
			cin >> line;
			field.push_back(line);
		}
		if (solve()) {
			cout << 0 << endl;
			continue;
		}
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < n - 1; j++) {
				if ((j == 0 || field[i][j - 1] == '0') && field[i][j] == '0' && (j + 1 == n - 1 || field[i][j + 1] == '0')) {
					field[i][j] = '1';
					if (solve()) {
						cout << i + 1 << ' ' << j + 1 << endl;
						goto NEXT;
					}
					field[i][j] = '0';
				}
			}
		}
		cout << 1 << endl;
NEXT:
		continue;
	}
}