#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int n, m, h, d;

int amida(vector<string> t) {
	int now = m;
	rep(i, 0, d) {
		if (t[i][now] == '1') now++;
		else if (now >= 1 && t[i][now - 1]=='1') now--;
	}
	return now;
}

signed main(){
	while (cin >> n && n) {
		cin >> m >> h >> d;
		m--; h--;
		vector<string> s(d+10), t(d+10);
		rep(i, 0, d) {
			cin >> s[i];
		}
		bool f = false;
		if (amida(s) == h) {
			cout << 0 << endl;
			f = true;
		}
		else {
			rep(i, 0, d) {
				rep(j, 0, n - 1) {
					t = s;
					if (t[i][j] == '0') {
						if (j != 0 && t[i][j - 1] == '1') continue;
						if (j != n - 2 && t[i][j + 1] == '1') continue;
						t[i][j] = '1';
						if (amida(t) == h) {
							f = true;
							cout << i + 1 << " " << j + 1 << endl;
						}
					}
					if (f) i = d + 1;
				}
			}
		}
		if (!f) cout << 1 << endl;
	}
}