#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	for (int n; cin >> n, n != 0; ) {
		int m; cin >> m;
		int g; cin >> g;
		int d; cin >> d;
		vector<string> amd(d);
		rep(i, d) cin >> amd[i];
		vi p(n);
		rep(i, n) p[i] = i;
		rep(i, d) rep(j, n - 1) if (amd[i][j] == '1') {
			swap(p[j], p[j + 1]);
		}
		if (p[g - 1] == m - 1) cout << 0 << endl;
		else {
			rep(k, d) rep(l, n - 1) {
				if (amd[k][l] == '1') continue;
				if (l > 0) if (amd[k][l - 1] == '1') continue;
				if (l + 1 < n - 1) if (amd[k][l + 1] == '1') continue;
				amd[k][l] = '1';
				rep(i, n) p[i] = i;
				rep(i, d) rep(j, n - 1) if (amd[i][j] == '1') {
					swap(p[j], p[j + 1]);
				}
				if (p[g - 1] == m - 1) {
					cout << k + 1 << ' ' << l + 1 << endl;
					goto next;
				}
				amd[k][l] = '0';
			}
			cout << 1 << endl;
			next:;
		}
	}
	return 0;
}