#include<iostream>
using namespace std;

int main()
{
  int n,m,a,d;
  for(;cin>>n,n;)
    {
      cin>>m>>a>>d;
      m--;
      a--;
      bool data[d][n-1];
      for(int i=0;i<d;i++)
	for(int j=0;j<n-1;j++)
	  {
	    char tmp;
	    cin>>tmp;
	    data[i][j]=(tmp=='1');
	  }
      int now=m;
      bool flag=true;
      for(int i=0;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)
	{
	  cout<<"0"<<endl;
	  flag=false;
	  continue;
	}
      else
	{
	  now=m;
	  for(int i=0;i<d;i++)
	    {
	      //     cout<<"now"<<now<<endl;
	      if(now-1>=0 && !data[i][now-1] &&
		 (now-2<0 || !data[i][now-2]))
		{
		  int now_tmp=now-1;
		  //	  cout<<"now_tmp"<<now_tmp<<endl;
		  for(int j=i+1;j<d;j++)
		    {
		      if(now_tmp-1>=0 && data[j][now_tmp-1])
			now_tmp=now_tmp-1;
		      else if(now_tmp<n-1 && data[j][now_tmp])
			now_tmp=now_tmp+1;
		    }
		  if(now_tmp==a)
		    {
		      //	      cout<<"a"<<endl;
		      cout<<i+1<<" "<<now<<endl;
		      flag=false;
		      break;
		    } 
		}
	      
	      if(now<n-1 && !data[i][now] &&
		 (now+1>=n-1 || !data[i][now+1]))
		{
		  int now_tmp=now+1;
		  for(int j=i+1;j<d;j++)
		    {
		      if(now_tmp-1>=0 && data[j][now_tmp-1])
			now_tmp=now_tmp-1;
		      else if(now_tmp<n-1 && data[j][now_tmp])
			now_tmp=now_tmp+1;
		    }
		  if(now_tmp==a)
		    {
		      //	      cout<<"b"<<endl;
		      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(now==a)
	    {
	      cout<<"0"<<endl;
	      flag=false;
	      continue;
	    }

	}

      if(flag)
      cout<<"1"<<endl;
    }
}