#include <stdio.h>

bool Simulation(char line[][15], int start, int goal, int m)
{
	int pos = start;
	
	for (int i = 0; i < m; i++){
		if (line[i][pos] == '1'){
			pos++;
		}
		else if (line[i][pos - 1] == '1'){
			pos--;
		}
	}
	return (pos == goal);
}

int main(void)
{
	int n, m;
	int start;
	int goal;
	char line[30][15];
	
	while (1){
		scanf("%d", &n);
		scanf("%d", &start);
		scanf("%d", &goal);
		scanf("%d", &m);
		
		for (int i = 0; i < m; i++){
			scanf("%s", line[i] + 1);
			line[i][0] = '0';
			line[i][n] = '0';
		}
		
		if (Simulation(line, start, goal, m) == true){
			puts("0");
			continue;
		}
		
		bool flag = false;
		for (int i = 0; i < m; i++){
			for (int j = 1; j < n; j++){
				if (line[i][j - 1] == '0' && line[i][j + 1] == '0' && line[i][j] == '0'){
					line[i][j] = '1';
					if (Simulation(line, start, goal, m) == true){
						printf("%d %d\n", i + 1, j);
						flag = true;
						break;
					}
					line[i][j] = '0';
				}
			}
			if (flag == true){
				break;
			}
		}
		
		if (flag == false){
			puts("1");
		}
	}
	
	return (0);
}