#include<iostream>
#include<cstring>

int n, m;
int l;
int d;
bool ver[30][8];

int sim( int v )
{
	for( int i = 0; i != d; ++i )
	{
		if( v < n - 2 && ver[i][v] )
			++v;
		else if( v > 0 && ver[i][v-1] )
			--v;
	}
	
	return v;
}

int main()
{
	while( std::cin >> n, n )
	{
		memset( ver, false, sizeof( ver ) );
		std::cin >> m >> l >> d;
		--m; --l;
		for( int i = 0; i != d; ++i )
		{
			for( int j = 0; j != n - 1; ++j )
			{
				char c;
				std::cin >> c;
				ver[i][j] = c - '0';
			}
		}

		if( sim( m ) == l )
			std::cout << 0 << std::endl;
		else
		{
			bool f = false;

			for( int i = 0; i != d; ++i )
			{
				for( int j = 0; j != n - 1; ++j )
				{
					if( !ver[i][j] && ( !j || !ver[i][j-1] ) && ( j == n - 2 || !ver[i][j+1] ) )
					{
						ver[i][j] = true;
						if( sim( m ) == l )
						{
							std::cout << i + 1 << " " << j + 1 << std::endl;
							f = true;
							goto end;
						}
						ver[i][j] = false;
					}
				}
			}

		end:;

			if( !f )
				std::cout << 1 << std::endl;
		}
	}

	return 0;
}