#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//?????§??¬?´???°
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
bool sfind(string s, string l) {//?????????1??????????????????2????????????
	for (ll i = 0; i <= s.size() - l.size(); i++) {
		str t = "";
		for (ll j = 0; j < l.size(); j++)
			t += s[i + j];
		if (t == l)
			return 1;
	}
	return 0;
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, m, h, d;
int a[30][10];
bool solve(int i, int j) {
	if (i == d) {
		if (j == h) return 1;
		return 0;
	}
	return solve(i + 1, a[i][j]);
}
signed main() {
	while (cin >> n&&n != 0) {
		cin >> m >> h >> d;
		m--, h--;
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < n; j++)
				a[i][j] = j;
		}
		for (int i = 0; i < d; i++) {
			string u;
			cin >> u;
			for (int j = 0; j < n - 1; j++) {
				bool t = (int)u[j] - '0';
				if (t)
					a[i][j] = j + 1, a[i][j + 1] = j;
			}
		}
		if (solve(0, m)) {
			cout << 0 << endl;
			continue;
		}
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < n - 1; j++) {
				if (a[i][j] == j&&a[i][j + 1] == j + 1) {
					a[i][j] = j + 1, a[i][j + 1] = j;
					if (solve(0, m)) {
						cout << i + 1 << " " << j + 1 << endl;
						goto stop;
					}
					a[i][j] = j, a[i][j + 1] = j + 1;
				}
			}
		}
		cout << 1 << endl;
	stop:;
	}
}