#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation etc.
#include <cstdlib>	// require abs
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
//#include <fstream>	// require freopen

using namespace std;

bool do_lot (vector<string> path, int n, vector <int> c, vector <int> e )
{
	int size = path.size();
	int i, j;

	for (i = 0; i < size; ++i ){
		for (j = 0; j < n - 1; ++j ){
			if (path[i][j] == '1' ){
				swap (c[j], c[j+1] );
			} // end if
		} // end for
	} // end for

	return (c == e );
}

bool isinsert_one (string str, int n )
{
	int len = str.length();
	str = '0' + str + '0';
	
	return (str[n+1-1] == '0' && str[n+1+1] == '0' );
} 

string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.dlII", "r", stdin );
	int n;

	while (cin >> n && n ){
		int m, h, d;
		cin >> m >> h >> d;
		vector <int> s(n, 0 ), e(n, 0 );
		string res = "";
	
		s[--m] = 1;
		e[--h] = 1;

		vector <string> path;
		int i, j;
		for (i = 0; i < d; ++i ) {
			string str = ""; 
			cin >> str;
			path.push_back (str );
		} // end for

		if (do_lot (path, n, s, e ) ){
			res += '0';
		}else{
			for (i = 0; i < d; ++i){
				for (j = 0; j < n - 1; ++j ){
					if (path[i][j] == '0' && isinsert_one (path[i], j ) ){
						path[i][j] = '1';
						if (do_lot (path, n, s, e ) ){
							res += itos (i+1);
							res += ' ';
							res += itos (j+1);
							goto result;
						}else{
							path[i][j] = '0';
						} // end if
					} // end if
				} // end for
			} // end for
		} // end if

result:
		if (res.empty() ){
			cout << '1' << endl;
		}else{
			cout << res << endl;
		} // end if
	} // end loop

	return 0;
}