#include<iostream>
using namespace std;
int n,m,a,d;
bool data[12][32];

bool check(int i,int now)
{
      for(;i<d;i++)
	{
	  if(now-1>=0 && data[i][now-1])
	    now=now-1;
	  else if(now<n-1 && data[i][now])
	    now=now+1;
	}
      if(now==a)
	return true;
      else 
	return false;
}

int main()
{
  for(;cin>>n,n;)
    {
      cin>>m>>a>>d;
      m--;
      a--;
      for(int i=0;i<d;i++)
	for(int j=0;j<n-1;j++)
	  {
	    char tmp;
	    cin>>tmp;
	    data[i][j]=(tmp=='1');
	  }

      bool flag=true;
      if(check(0,m))
	cout<<"0"<<endl;
      else
	{
	  int now=m;
	  for(int i=0;i<d;i++)
	    {
	      if(now-1>=0 && !data[i][now-1] &&
		 (now-2<0 || !data[i][now-2]))
		{
		  if(check(i,now-1))
		    {
		      cout<<i+1<<" "<<now<<endl;
		      flag=false;
		      break;
		    }
		}
	      if(now<n-1 && !data[i][now] &&
		 (now+1>=n-1 || !data[i][now+1]))
		{
		  if(check(i,now+1))
		    {
		      cout<<i+1<<" "<<now+1<<endl;
		      flag=false;
		      break;
		    }		  
		}
	      if(now-1>=0 && data[i][now-1])
		now=now-1;
	      else if(now<n-1 && data[i][now])
		now=now+1;
	    }
	}
      if(flag)
	cout<<"1"<<endl;
    }
}