#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0){
			break;
		}
		int m;
		cin >> m;
		int g;
		cin >> g;
		int d;
		cin >> d;
		vector<string> yoko(d);
		for (int i = 0; i < d; i++) {
			cin >> yoko[i];
		}
		vector< vector<int> > dp(d+1, vector<int>(n, 0));
		for (int i = 0; i < n; i++) {
			dp[0][i] = i+1;
		}
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < n; j++) {
				dp[i+1][j] = dp[i][j];
			}
			for (int j = 0; j < yoko[i].size(); j++) {
				if (yoko[i][j] == '1') {
					swap(dp[i+1][j], dp[i+1][j+1]);
				}
			}
		}/*
		for (int i = 0; i < d+1; i++) {
			for (int j = 0; j < n; j++) {
				cout << dp[i][j];
			}
			cout << endl;
		}*/
		if (dp[d][g-1] == m) {
			cout << 0 << endl;
		} else {
			bool h = false;
			int aa, bb;
			aa = bb = 0;
			for (int i = 1; i <= d; i++) {
				for (int j = 0; j < n-1; j++) {
					if ((dp[i][j] == m && dp[i][j+1] == dp[d][g-1]) || (dp[i][j] == dp[d][g-1] && dp[i][j+1] == m)) {
						//cout << i << endl;
						if (yoko[i-1][j] == '0') {
							//cout << i << ' ' << j << endl;
							if (j == 0 && yoko[i-1][j+1] == '0') {
								h = true;
								aa = i;
								bb = j+1;
								break;
							} else if (j == n-2 && yoko[i-1][j-1] == '0'){
								h = true;
								aa = i;
								bb = j+1;
								break;
							} else if (yoko[i-1][j-1] == '0' && yoko[i-1][j+1] == '0') {
								h = true;
								aa = i;
								bb = j+1;
								break;
							}
						}
					}
					if (h) {
						break;
					}
				}
			}
			if (h) {
				cout << aa << ' ' << bb << endl;
			} else {
				cout << 1 << endl;
			}
		}
	}
	return 0;
}