#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T = int>inline T in() { T x; cin >> x; return x; }
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REP1(i,n) for(ll i=1;i<=(n);++i)
#define REPI(i,ini,n) for(ll i=(ini);i<(n);++i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b) (((a)+(b)-1)/(b))
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1e9
#define INFL static_cast<ll>(INF)
bool solve_amida(int col, int row, char**pass, int s, int g)
{
	int x = s;
	REP(y, row)
	{
		if (x != 1 && pass[y][x - 2] == '1')--x;
		else if (x != col && pass[y][x - 1] == '1')++x;
	}
	return x == g;
}
int main()
{
	while (true)
	{
		int col = in(); if (col == 0)break;
		int s = in(), g = in(), row = in();
		char**pass = new char*[row];
		REP(i, row)
		{
			pass[i] = new char[col - 1];
			REP(j, col - 1)pass[i][j] = in<char>();
		}
		if (solve_amida(col, row, pass, s, g))cout << '0' << endl;
		else
		{
			REP(i, row)
			{
				REP(j, col - 1)
				{
					if (pass[i][j] == '0' && (j == 0 || pass[i][j - 1] == '0') && (j == col - 2 || pass[i][j + 1] == '0'))
					{
						pass[i][j] = '1';
						if (solve_amida(col, row, pass, s, g))
						{
							cout << i + 1 << ' ' << j + 1 << endl;
							goto roop_end;
						}
						pass[i][j] = '0';
					}
				}
			}
			cout << '1' << endl;
		roop_end:;
		}
	}
}
