#include <iostream>
using namespace std;

#define N 10
#define D 30

int lot[N+2][D];
int n,d;

int simulate(int from){
  int x = from;
  for (int i=0; i<d; i++){
    if (lot[x][i]) x--;
    else if (lot[x+1][i]) x++;
  }
  return x;
}

int main(void){
  int st,rwd, flg;
  char c;
  
  while (cin >> n){
    if (n==0) break;
    cin >> st >> rwd >> d;
    st--; rwd--; // 1-orgin -> 0-origin
    for (int i=0; i<d; i++){
      lot[0][i] = lot[n][i] = 0;
      for (int j=1; j<n; j++){
        cin >> c;
        lot[j][i] = c-'0';
      }
    }
    if (simulate(st)==rwd){
      cout << 0 << endl;
    } else {
      flg = 0;
      for (int i=0; i<d; i++){
        for (int j=1; j<n; j++){
          if (flg) continue;
          if (lot[j][i]==0 && lot[j-1][i]==0 && lot[j+1][i]==0){
            lot[j][i]=1;
            if (simulate(st)==rwd){
              cout << (i+1) << " " << (j) << endl;
              flg = 1;
            }
            lot[j][i] = 0;
          }
        }
      }
      if (flg==0) cout << 1 << endl;
    }
  }
  return 0;
}
