#include <iostream>
#include <string>
using namespace std;
bool f(){
}
int main(){
  int n,m,h,d;
  while(cin>>n&&n){
    cin>>m>>h>>d;
    string s[d];
    int x=m-1,y=h-1;
    for(int i=0;i<d;++i){
      cin>>s[i];
      if(x<n-1&&s[i][x]=='1') ++x;
      else if(x-1>=0&&s[i][x-1]=='1') --x;
    }
    if(x==h-1){
      cout<<0<<endl;continue;
    }
    x=m-1;
    for(int i=d-1;i>=0;--i){
      if(y<n-1&&s[i][y]=='1') ++y;
      else if(y-1>=0&&s[i][y-1]=='1') --y;
    }
    bool f=true;
    for(int i=0;i<d;++i){
      if(x==y-1&&s[i][x]=='0'&&(x==0||s[i][x-1]=='0')&&(x==3||s[i][x+1]=='0')){
	cout<<i+1<<" "<<x+1<<endl;f=false;break;
      }
      else if(x==y+1&&s[i][x-1]=='0'&&(x==1||s[i][x-2]=='0')&&(x==4||s[i][x]=='0')){
	cout<<i+1<<" "<<x<<endl;f=false;break;
      }
      if(x<n-1&&s[i][x]=='1') ++x;
      else if(x-1>=0&&s[i][x-1]=='1') --x;
      if(y<n-1&&s[i][y]=='1') ++y;
      else if(y-1>=0&&s[i][y-1]=='1') --y;
    }
    if(f) cout<<1<<endl;
  }
  return 0;
}