
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>

#define INF (1<<21)
#define swap(a,b) {a=a+b; b=a-b; a=a-b;}
#define min(a,b) {a > b ? b:a}
#define max(a,b) {a > b ? a:b}
using namespace std;

//300*300??§???????????§??¨??¢?´¢
#define MAX_N 10
#define MAX_D 30
bool t[MAX_N - 1][MAX_D];
int n, m, goal, d;

bool checkAmida() {
	int amida[] = {0,1,2,3,4,5,6,7,8,9};
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n - 1; j++) {
			if (t[j][i]) swap(amida[j], amida[j + 1])
		}
	}
	return amida[goal - 1] == m-1;
}

pair<int,int> addOneLine() {
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n - 1; j++) {
			if ((j - 1 >= 0) && t[j - 1][i]) continue;
			if (t[j][i]) continue;
			if ((j + 1 < n - 1) && t[j + 1][i]) continue;
			t[j][i] = true;
			if (checkAmida()) return make_pair(i,j);
			t[j][i] = false;
		}
	}
	return make_pair(-1, -1);
}
void q69() {
	for (; ;) {
		scanf("%d\n", &n);
		if (!n) break;
		scanf("%d\n%d\n%d\n", &m,&goal, &d);
		for (int i = 0; i < d; i++) {
			char tmp;
			for (int j = 0; j < n - 1; j++) {
				scanf("%c", &tmp);
				t[j][i] = tmp == '0' ? false : true;
			}
			scanf("%c", &tmp);
		}
		if (checkAmida()) {
			cout << "0" << endl;
			continue;
		}
		
		pair<int, int> point = addOneLine();
		if (point.first != -1) {
			cout << point.first+1 << " " << point.second+1 << endl;
		}
		else {
			cout << "1" << endl;
		}

	}
}
int main() {
	q69();
	return 0;
}