#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int n,m,t,d;
int ba[9][30];

bool go() {
  int p = m;
  REP(i,d) {
    if (p>0&&ba[p-1][i]) p--;
    else if (p<n-1&&ba[p][i]) p++;
  }
  return (p==t);
}
int main() {
  while(cin>>n,n) {
    cin>>m>>t>>d;
    m--;
    t--;
    REP(i,d) {
      REP(j,n-1) {
        char c;
        cin >> c;
        ba[j][i] = c-'0';
      }
    }
    if (go()) {
      cout << 1 << endl;
      return 0;
    }
    REP(i,d) {
      REP(j,n-1) {
        if (ba[j][i]==0) {
          ba[j][i] = 1;
          if (go()) {
            printf("%d %d\n",i+1,j+1);
            return 0;
          }
          ba[j][i] = 0;
        }
      }
    }
    cout << 0 << endl;
  }
}