#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>

using namespace std;

int main(){

	int n,start,goal,height,table[10],to_change,min_row,min_col;
	char buf[30][11];
	bool FLG;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 0; i < n; i++)table[i] = i;

		scanf("%d",&start);
		start--;

		scanf("%d",&goal);
		goal--;

		scanf("%d",&height);

		for(int i = 0; i < height; i++){
			scanf("%s",buf[i]);
			for(int k = 0; buf[i][k] != '\0';k++){
				if(buf[i][k] == '1'){
					swap(table[k],table[k+1]);
				}
			}
		}

		if(table[goal] == start){
			printf("0\n");
		}else{
			to_change = table[goal];

			for(int i = 0; i < n; i++)table[i] = i;

			FLG = false;
			for(int i = 0; i < height; i++){

				for(int k = 0; k <= n-2; k++){
					if((table[k] == start && table[k+1] == to_change) || (table[k] == to_change && table[k+1] == start)){
						if(k == 0){
							if((n == 2 && buf[i][k] == '0') || (n > 2 && buf[i][k] == '0' && buf[i][k+1] == '0')){
								min_row = i;
								min_col = k;
								FLG = true;
								break;
							}
						}else{
							if((k < n-2 && buf[i][k-1] == '0' && buf[i][k] == '0' && buf[i][k+1] == '0') ||
									(k == n-2 && buf[i][k-1] == '0' && buf[i][k] == '0')){
								min_row = i;
								min_col = k;
								FLG = true;
								break;
							}
						}
					}
				}
				if(FLG)break;

				for(int k = 0; buf[i][k] != '\0';k++){
					if(buf[i][k] == '1'){
						swap(table[k],table[k+1]);
					}
				}
			}

			if(!FLG)printf("1\n");
			else{
				printf("%d %d\n",min_row+1,min_col+1);
			}

		}

	}

	return 0;
}