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

const int MAXD = 40;

int test(int n, int m, int d, const string s[]) {
  for(int i = 0; i < d; ++i) {
    if(m != 0 && s[i][m-1] == '1') {
      --m;
    } else if(m != n-1 && s[i][m] == '1') {
      ++m;
    }
  }
  return m;
}

int main() {
  int n, m, atari, d;
  string s[MAXD];
  while(cin >> n && n) {
    cin >> m >> atari >> d;
    --m; --atari;
    for(int i = 0; i < d; ++i) {
      cin >> s[i];
    }
    if(test(n,m,d,s) == atari) {
      cout << 0 << endl;
    } else {
      bool flag = false;
      for(int i = 0; !flag && i < d; ++i) {
        for(int j = 0; !flag && j < n-1; ++j) {
          if(s[i][j] == '0' &&
             (j == 0 || s[i][j-1] == '0') &&
             (j == n-2 || s[i][j+1] == '0')) {
            s[i][j] = '1';
            if(test(n,m,d,s) == atari) {
              cout << i+1 << " " << j+1 << endl;
              flag = true;
              break;
            }
            s[i][j] = '0';
          }
        }
      }
      if(!flag) cout << 1 << endl;
    }
  }
  return 0;
}