#include <bits/stdc++.h>

using namespace std;

int n, m, g, d;
int position[12];
bool lotsData[32][12];

void initPosition() {
	for (int i = 0; i < n; ++i) {
		position[i] = i;
	}
}

void judgePosition()
{
	for (int i = 0; i < d; ++i)
	{
		for (int j = 0; j < n - 1; ++j)
		{
			if (lotsData[i][j])
				swap(position[j], position[j + 1]);
		}
	}
}

int main()
{
	int row, col;
	char buf[16];
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (scanf("%d", &n), n) {
		initPosition();
		scanf("%d%d%d", &m, &g, &d);
		--m;
		--g;
		
		for (int i = 0; i < d; ++i)
		{
			scanf("%s", buf);
			for (int j = 0; buf[j] != '\0'; ++j) {
				lotsData[i][j] = (buf[j] == '1');
			}
				
		}

		judgePosition();
		if (position[g] == m)
		{
			puts("0");
			continue;
		}

		bool flag = false;
		for (row = 0; row < d; row++)
		{
			for (col = 0; col < n - 1; col++)
			{
				if(lotsData[row][col]
					|| (col != 0 && lotsData[row][col - 1])
					|| (col != n - 2 && lotsData[row][col + 1])) {
					continue;
				}
		
				lotsData[row][col] = true;
				initPosition();

				judgePosition();
				if (position[g] == m)
				{
					flag = true;
					break;
				}
				lotsData[row][col] = false;
			}
			if (flag) {
				break;
			}	
		}
		if (flag) {
			printf("%d %d\n", row + 1, col + 1);
			//cout << row + 1 << ends << col + 1 << endl;
		}
		else {
			puts("1");
		}
	}

	return 0;
}
