#include<iostream>
#include<cstring>

using namespace std;

const int MAX = 12;

bool cross[MAX][MAX];
int n,start,goal,d;


void init(){
  memset(cross,false,sizeof(cross));
}

bool move(){
  int pos = start;
  for(int i = 0; i < d; i++){
    if(cross[i][pos]) pos++;
    else if(cross[i][pos-1]) pos--;
  }
  return pos == goal;
}


bool addline(){

  for(int i = 1; i <= d; i++)
    for(int j = 1; j < n; j++)
      if(!cross[i][j] && !cross[i][j-1] && !cross[i][j+1]){
	cross[i][j] = true;
	if(move()){
	  cout << i << " " << j+1 << endl;
	  return true;
	}
	cross[i][j] = false;
      }

  return false;
}

void solve(){

  if(move()) cout << "0" << endl;
  else if(addline()) return;
  else cout << "1" << endl;
}

int main(){
  while(cin >> n && n){
    init();
    cin >> start >> goal >> d;

    for(int i = 1; i <= d; i++)
      for(int j = 1; j < n; j++){
	char c;
	cin >> c;
	if(c == '1') cross[i][j] = true;
	else cross[i][j] = false;
      }
    
    solve();
  }
  return 0;
}