#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, m, atari, d;
string s[35];
int a[35][11];
signed main() {
	while (cin >> n, n) {
		cin >> m >> atari >> d;
		for0(i, d)cin >> s[i];
		for1(i, n)a[0][i] = i;
		for1(j, d) {
			for1(i, n)a[j][i] = a[j - 1][i];
			for0(i, n - 1)if (s[j - 1][i] == '1')swap(a[j][i + 1], a[j][i + 2]);
		}
		atari = a[d][atari];
		if (atari == m) {
			printf("0\n");
			continue;
		}
		for1(j, d) {
			for0(i, n - 1) {
				if (s[j - 1][i] == '1')continue;
				if (i > 0)if (s[j - 1][i - 1] == '1')continue;
				if (i < n - 1)if (s[j - 1][i + 1] == '1')continue;
				if (a[j][i + 2] == m && a[j][i + 1] == atari) {
					cout << j << ' ' << i + 1 << endl;
					goto heaven;
				}
				if (a[j][i + 2] == atari && a[j][i + 1] == m) {
					cout << j << ' ' << i + 1 << endl;
					goto heaven;
				}
			}
		}
		printf("1\n");
	heaven:;
	}
}
