#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	while(cin>>n,n)
	{
		int m,hit,d;
		cin>>m>>hit>>d;

		string f[d];
		for(int i = 0; i < d; ++i)
		{
			cin>>f[i];
		}

		int x=m,y=1;
		while(y<=d)
		{
			if(x-2>=0&&f[y-1][x-2]=='1')
			{
				x=x-1;
			}
			else if(x-1<f[0].size()&&f[y-1][x-1]=='1')
			{
				x=x+1;
			}
			y++;
		}
		if(x==hit)
		{
			cout<<0<<endl;
			continue;
		}
		bool flag=false;
		for(int i = 0; i < d; ++i)
		{
			for(int j = 0; j < f[0].size(); ++j)
			{
				x=m; y=1;
				if(f[i][j]=='1'||(j>0&&f[i][j-1]=='1')||(j<f[0].size()-1&&f[i][j+1]=='1')) continue;
				f[i][j]='1';
				while(y<=d)
				{
					if(x-2>=0&&f[y-1][x-2]=='1')
					{
						--x;
					}
					else if(x-1<f[0].size()&&f[y-1][x-1]=='1')
					{
						++x;
					}
					y++;
				}
				if(x==hit)
				{
					cout<<i+1<<" "<<j+1<<endl;
					flag=true;
					break;
				}
				f[i][j]='0';
			}
			if(flag) break;
		}
		if(!flag) cout<<1<<endl;
	}
  return 0;
}