#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int n, start, goal, d;

bool check(const vector< vector<char> >& amida, int pos)
{
	for (int i = 0; i < d; ++i)
	{
		if (pos == 0)
		{
			if (amida[i][pos] == '1')
			{
				pos = 1;
			}
		}
		else if (pos == n - 1)
		{
			if (amida[i][pos - 1] == '1')
			{
				pos = n - 2;
			}
		}
		else
		{
			if (amida[i][pos - 1] == '1')
			{
				pos = pos - 1;
			}
			else if (amida[i][pos] == '1')
			{
				pos = pos + 1;
			}
		}
	}
	if (pos == goal)
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

void solve()
{
	while (cin >> n, n)
	{
		cin >> start >> goal >> d;
		--start; --goal;
		vector< vector<char> > amida(d, vector<char>(n - 1));
		for (int i = 0; i < d; ++i)
		{
			for (int j = 0; j < n - 1; ++j)
			{
				cin >> amida[i][j];
			}
		}
		int pos = start;
		if (check(amida, pos))
		{
			cout << 0 << endl;
			goto END;
		}
		for (int i = 0; i < d; ++i)
		{
			for (int j = 0; j < n - 1; ++j)
			{
				if (amida[i][j] == '1' || (j - 1 >= 0 && amida[i][j - 1] == '1') || (j + 1 < n - 1 && amida[i][j + 1] == '1'))
				{
					continue;
				}
				amida[i][j] = '1';
				pos = start;
				if (check(amida, pos))
				{
					cout << i + 1 << " " << j + 1 << endl;
					goto END;
				}
				amida[i][j] = '0';
			}
		}
		cout << 1 << endl;
	END:
		;
	}
}

int main()
{
	solve();
	return(0);
}