#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

int n, S, G, d;
string line[31];

bool solve(){
  int row = S;
  for(int i = 0 ; i < d ; i++){
    if(line[i][row] == '1') row++;
    else if(line[i][row-1] == '1') row--;
  }
  if(row == G) return true;
  else return false; 
}

int main(){
  while(cin >> n, n){
    //    if(n == 0) break;
    cin >> S >> G >> d;
    for(int i = 0 ; i < d ; i++){      
      cin >> line[i];
      line[i] = "0" + line[i] + "0";
    }
    
    if(solve()){
      cout << 0 << endl;
      continue;
    }
    
    bool flag = false;
    for(int i = 0 ; i < d ; i++){
      for(int j = 1 ; j < n ; j++){
	if(line[i][j] == '1' ||
	   line[i][j-1] == '1' || line[i][j+1] == '1') continue;
	line[i][j] = '1';
	if(solve()){
	  flag = true;
	  cout << i+1 << ' ' << j << endl;
	  i = d, j = n;
	}
	else line[i][j] = '0';
      }
    }
    if(!flag) cout << 1 << endl;
  }
  return 0;
}