#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<queue>
using namespace std;

int k[10];
string s[30];
signed main(){
	int a;
	while (cin >> a, a) {
		for (int i = 0; i < a; i++)k[i] = i;
		int b, c, d; cin >> b >> c >> d;
		for (int e = 0; e < d; e++) {
			string f; cin >> f;
			s[e] = "0" + f + "0";
			for (int g = 0; g < a - 1; g++) {
				if (f[g] == '1') {
					swap(k[g], k[g + 1]);
				}
			}
		}
		b--; c--;
		int atari = k[c];
		if (b == atari) { puts("0"); continue; }
		for (int i = 0; i < a; i++)k[i] = i;
		for (int i = 0; i < d; i++) {
			for (int j = 1; j < a; j++) {
				if (s[i][j] == '1') {
					swap(k[j - 1], k[j]);
				}
				else {
					if (s[i][j - 1] == '0'&&s[i][j + 1] == '0') {
						if ((k[j - 1] == atari&&k[j] == b) || (k[j] == atari&&k[j - 1] == b)) {
							cout << i + 1 << " " << j << endl;
							goto l;
						}
					}
				}
			}
		}
		puts("1");
	l:;
	}
}