#include <iostream>
#include <string>
using namespace std;

bool solveLot( int* sl, int row, int col, int start, int goal ){
	int cur = start;
	for ( int i = 0; i < row; ++i ){
		if ( sl[ i * ( col + 1 ) + ( cur - 1 ) ] ){
			--cur;
		}else if( sl[ i * ( col + 1 ) + cur ] ){
			++cur;
		}
	}
	return ( cur == goal );
}

int main(){
	int col, row, start, goal;
	string s;

	while ( cin >> col  && col ){
		cin >> start;
		cin >> goal;
		cin >> row;
		int* swapLine = new int[ row * ( col + 1 ) ];

		for ( int i = 0; i < row; ++i ){
			cin >> s;
			for ( int j = 0; j < col+1; ++j ){
				if ( j == 0 || j == col ){
					swapLine[ i * ( col + 1 ) + j ] = 0;
				}else{
					swapLine[ i * ( col + 1 ) + j ] = static_cast< int >( s[ j - 1 ] - '0' );
				}
			}
		}

		if ( solveLot( swapLine, row, col, start, goal ) ){
			cout << "0" << endl;
		}else{
			int* plusLine = new int[ row * ( col + 1 ) ];
			for ( int i = 0; i < row; ++i ){
				for ( int j = 0; j < col+1; ++j ){
					plusLine[ i * ( col + 1 ) + j ] = 0;
					if ( !( j == 0 || j == col )
						&& !swapLine[ i * ( col + 1 ) + ( j - 1 ) ]
						&& !swapLine[ i * ( col + 1 ) + j ]
						&& !swapLine[ i * ( col + 1 ) + ( j + 1 ) ] ){
							plusLine[ i * ( col + 1 ) + j ] = 1;
					}
				}
			}

			bool solved = false;
			for ( int i = 0; i < row; ++i ){
				for ( int j = 0; j < col+1; ++j ){
					if ( plusLine[ i * ( col + 1 ) + j ] ){
						swapLine[ i * ( col + 1 ) + j ] = 1;
						if ( solveLot( swapLine, row, col, start, goal ) ){
							cout << i+1 << " " << j << endl;
							solved = true;
							break;
						} else {
							swapLine[ i * ( col + 1 ) + j ] = 0;
						}
					}
				}
				if ( solved ) break;
			}

			if ( !solved ){
				cout << "1" << endl;
			}

			delete[] plusLine;
		}

		delete[] swapLine;
	}

	return 0;
}