#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int N, S, G, D;

bool check(vector<string> &v){
  int now = S;
  REP(i, v.size()){
    if(now != 0 && v[i][now - 1] == '1') --now;
    else if(now + 1 != (int)(v.size()) && v[i][now] == '1') ++now;
  }
  return now == G;
}

bool solve(vector<string> &v){
  REP(i, v.size()){
    REP(j, v[i].size()){
      if(v[i][j] == '1') continue;
      if(j != 0 && v[i][j - 1] == '1') continue;
      if(j + 1 != (int)(v[i].size()) && v[i][j] == '1') continue;
      v[i][j] = '1';
      if(check(v)){
        cout <<i + 1 <<" " <<j + 1 <<endl;
        return 1;
      }
      v[i][j] = '0';
    }
  }
  return false;
}

int main(){
  while(cin >>N && N){
    cin >>S >>G >>D;
    --S; --G;
    vector<string> v(D);
    REP(i, D) cin >>v[i];
    if(check(v)) cout <<0 <<endl;
    else if(!solve(v)) cout <<1 <<endl;
  }
  return 0;
}