#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n,m,hoshi,d;
char maze[32][16];

bool judge(){
  int point =m-1;
  for(int i  =0;i < d;i++){
    if(point==0){
      if(maze[i][point]=='1'){
	point +=1;
      }
    }
    else if(point ==n-1){
      if(maze[i][point-1]=='1'){
	point -=1;
      }
    }
    else{
      if(maze[i][point-1] =='1')
	point -=1;
      else if(maze[i][point]=='1')
	point +=1;
    }
  }
  if(point ==hoshi)
    return true;
  return false;
}

int main()
{
  while(cin>>n,n){
    scanf("%d%d%d",&m,&hoshi,&d);
    hoshi -=1;
    for(int i =0;i < d;i++){
      cin>>maze[i];
    }
    if(judge())
      cout <<"0"<<endl;
    else{
      int x,y;
      bool f = false;
      for(int i =0;i <d&&!f;i++){
	for(int j = 0;j <n-1&&!f;j++){
	  if(maze[i][j]=='0'&&(maze[i][j-1]!='1'&&maze[i][j+1]!='1')){
	    maze[i][j] ='1';
	    if(judge()){
	      f = true;
	      x = j;
	      y = i;
	      break;
	    }
	    maze[i][j]='0';
	  }
	}
      }
      if(f)
	cout <<y+1<<" "<<x+1<<endl;
      else
	cout <<"1"<<endl;
    }
  }
	    
  return 0;
}