#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;


int n, m, g, d;
int s[9];
bool l[30][8];
int works[9];
bool workl[30][8];

void shuffle()
{
	for (int i = 0 ; i < d; ++i)
	{
		for (int j = 0; j < n-1; ++j)
		{
			if (workl[i][j])
				swap(works[j], works[j+1]);
		}
	}
}

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

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

		scanf("%d\n%d\n%d\n", &m, &g, &d);
		--m;
		--g;

		for (int i = 0; i < d; ++i)
		{
			char buf[9];
			scanf("%s\n", buf);
			for (int j = 0; j < n-1; ++j)
				l[i][j] = buf[j] == '1';
		}

		memcpy(works, s, sizeof(works));
		memcpy(workl, l, sizeof(workl));
		shuffle();
		if (works[g] == m)
		{
			puts("0");
			continue;
		}

		int x, y;
		bool ok = false;
		for (y = 0; y < d; ++y)
		{
			for (x = 0; x < n-1; ++x)
			{
				if (l[y][x]
					|| (x != 0 && l[y][x-1])
					|| (x != n-2 && l[y][x+1])
					)
					continue;

				memcpy(works, s, sizeof(works));
				memcpy(workl, l, sizeof(workl));
				workl[y][x] = true;

				shuffle();
				if (works[g] == m)
				{
					ok = true;
					break;
				}
			}
			if (ok)
				break;
		}
		if (ok)
			printf("%d %d\n", y+1, x+1);
		else
			puts("1");
	}

	return 0;
}