#include<iostream>
#include<algorithm>
using namespace std;

int n, m, idx, d;
bool amd[30][9];

bool solve(int now = m - 1,int y = 0){
  if(y == d) return now + 1 == idx;
  if(now && amd[y][now - 1]) return solve(now - 1, y + 1);
  if(now != n - 1 && amd[y][now]) return solve(now + 1, y + 1);
  return solve(now, y + 1);
}
int main(){
  while(cin >> n , n){
    cin >> m >> idx >> d;
    char c;
    for(int i = 0; i < d ; i++ ){
      for(int j = 0 ; j < n - 1 ; amd[i][j++] = c - '0' ){
        cin >> c;
      }
    }
    if(solve()){
      cout << 0 << endl;
      continue;
    }
    bool ok = false;
    for(int i = 0 ; i < d && !ok; i++ ){
      for(int j = 0 ; j < n - 1 && !ok ; j++ ){
        if(amd[i][j] || (j & amd[i][j-1]) || (j != n - 2 & amd[i][j+1])) continue;
        amd[i][j] = true;
        if(solve()) cout << i+1 << " " << j+1 << endl, ok++; // break
        else amd[i][j] = false;
      }
    }
    if(!ok) cout << 1 << endl;
  }
}