#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/

int n,m, p, d;
bool b[32][12];
int amida()
{
	int now = m;
	for (int i = 0; i <= d + 1; i++)
	{
		if (b[i][now])now = now + 1;
		else if (b[i][now - 1])now = now - 1;
	}
	return now;
}

int main()
{
	
	while (cin >> n&&n)
	{
		bool ok = true;
		memset(b, 0, sizeof b);
		cin >> m >> p >> d;
		for (int i = 1; i <= d; i++)
		{
			for (int l = 1; l < n; l++)
			{
				char c;
				cin >> c;
				b[i][l] = c == '1';
			}
		}

		if (amida()==p)
		{
			cout << 0 << endl;
			continue;
		}
		for (int i = 1; i <= d&&ok; i++)
		{
			for (int l = 1; l < n; l++)
			{
				if (b[i][l] == 0 && b[i][l - 1] == 0 && b[i][l + 1] == 0)
				{
					b[i][l] = true;
					if (amida() == p)
					{
						cout << i << " "<<l << endl;
						ok = false;
						break;
					}
					b[i][l] = false;
				}
			}
		}
		if (ok)
		{
			cout << 1 << endl;
		}
	}
}