#include <stdio.h>

int main(void)
{
	int n,d;
	int mi,co;
	int c_num;
	int a[50][20];
	int dummy;
	int ansx,ansy;
	char c[100][20];

	scanf("%d", &n);
	while(n != 0){
		for(int i = 1; i <= n; i++){
			a[0][i] = i;
		}
		scanf("%d", &mi);
		scanf("%d", &co);
		scanf("%d", &d);

		for(int i = 0; i < d; i++){
			scanf("%s", &c[i]);
			for(int j = 1; j <= n; j++){
				a[i + 1][j] = a[i][j];
			}
			for(int j = 0; j < n - 1; j++){
				if(c[i][j] == '1'){
					dummy = a[i + 1][j + 1];
					a[i + 1][j + 1] = a[i + 1][j + 2];
					a[i + 1][j + 2] = dummy;
				}
			}
			for(int j = 1; j <= n; j++){
				//printf("%d ",a[i + 1][j]);
			}
			//printf("\n");
		}
		c_num = a[d][co];
		//printf("%d\n",c_num);

		ansx = 0;
		ansy = 0;

		if(c_num == mi){
			printf("0\n");
		}else{
			for(int i = d - 1; i >= 0; i--){
				for(int j = 1; j <= n - 1; j++){
					if(((a[i][j] == mi && a[i][j + 1] == c_num) || (a[i][j + 1] == mi && a[i][j] == c_num)) &&c[i][j - 2] != '1' && c[i][j - 1] != '1' && c[i][j] != '1'){
						ansy = i + 1;
						ansx = j;
					}
				}
			}
			if(ansy != 0 && ansx != 0){
				printf("%d %d\n",ansy,ansx);
			}else{
				printf("1\n");
			}
		}
		scanf("%d", &n);
	}
	return 0;
}