#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int v[10];
int w[30][10];
int x[30][10];
int main()
{
  int n,m,a,d,i,j;
  while(cin >> n, n){
    memset(v,0,sizeof(v));
    memset(w,0,sizeof(w));
    memset(x,0,sizeof(x));
    cin >> m >> a >> d;
    for(i=1;i<=n;i++){
      v[i] = i;
    }
    string s;
    for(i=0;i<d;i++){
      cin >> s;
      for(j=0; j<s.length(); j++){
	x[i][j+1] = s[j] - '0';
	if(s[j] == '1') swap(v[j+1],v[j+2]);
      }
      for(j=1;j<=n;j++){
	w[i][j] = v[j];
      }
    }
    if(w[d-1][a] == m) {
      cout << "0" << endl;
      continue;
    }
    for(i=0;i<d;i++){
      for(j=1;j<n;j++){
	if(x[i][j-1] + x[i][j] + x[i][j+1] == 0 &&
	   (w[i][j] == w[d-1][a] && w[i][j+1] == m ||
	    w[i][j] == m && w[i][j+1] == w[d-1][a])) break;
      }
      if(j != n) break;
    }
    if(i != d) cout << (i+1) << " " << j << endl;
    else cout << "1" << endl;
  }
  return 0;
}