#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int n, m, hit, d;
string inp;
bool amida[30][9];
int top[11];

bool hantei()
{
	//debug
	/*
	rep(i, d)
	{
		rep(j, n-1)
		{
			cout << amida[i][j] ? "1" : "0";
		}
		cout << endl;
	}
	*/

	for (int i=1; i<=n; i++) top[i] = i;
	rep(i, d) rep(j, n-1)
	{
		if (amida[i][j])
		{
			int tmp = top[j+1];
			top[j+1] = top[j+2];
			top[j+2] = tmp;
		}
	}
	//for (int i=1; i<=n; i++) cout << top[i] << " ";
	if (top[hit] == m)
	{
		//cout << "true" << endl;
		return true;
	} else {
		//cout << "false" << endl;
		return false;
	}
}

int main()
{
	while (cin >> n, n)
	{
		cin >> m >> hit >> d;
		rep(i, d)
		{
			cin >> inp;
			rep(j, inp.length())
			{
				amida[i][j] = inp[j] == '1' ? true : false;
			}
		}

		bool tukeru = false;

		if (hantei())
		{
			cout << 0 << endl;
			continue;
		} else {
			//amida[][]を修正しながら全探索
			rep(i, d)
			{
				bool exit1 = false;
				rep(j, n - 1)
				{
					bool exit2 = false;
					int nx[] = {-1, 1};
					bool flag = true;	//その位置に横棒を追加できるか
					if (!amida[i][j])
					{
						rep(k, 2)
						{
							if (0 <= j + nx[k] && j + nx[k] < n - 1 && amida[i][j + nx[k]]) flag = false;
						}
						if (flag)
						{
							//printf("i = %d, j = %d\n", i, j);
							amida[i][j] = true;	
							if (hantei())
							{
								cout << i + 1 << " " << j + 1 << endl;
								exit1 = exit2 = true;
								tukeru = true;
							}
							amida[i][j] = false;
						}
					}
					if (exit2) break;
				}
				if (exit1) break;
			}
		}
		if (!tukeru) cout << 1 << endl;
	}

	return 0;
}