#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, col = 0;
  
  while(1){
    if(col == d) break;
    if(line[col][row] == '1') col++, row++;
    else if(line[col][row-1] == '1') col++, row--;
    else col++;
  }
  if(row == G) return true;
  else return false; 
}
  
int main(){
  while(cin >> n, n){
    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;
    else{
       bool flag = false;
      for(int i = 0 ; i < d ; i++){
	if(flag) break;
	for(int j = 1 ; j < line[i].size() ; 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;
	  }
	  else line[i][j] = '0';
	}
      }
      if(!flag) cout << 1 << endl;
    }
  }
  return 0;
}