#include <iostream>

using namespace std;

int n, st, gl, h;
char a[31][11];
bool dfs(int p, int q)
{
  if(q == h){
    if(p == gl) return true;
    return false;
  }

  if(p == 0){
    if(a[q][p] == '1') return dfs(p+1, q+1);
  } else if(p == n-1){
    if(a[q][p-1] == '1') return dfs(p-1, q+1);
  } else {
    if(a[q][p-1] == '1') return dfs(p-1, q+1);
    if(a[q][p] == '1') return dfs(p+1, q+1);
  }

  return dfs(p, q+1);
}

bool check(int q, int p)
{
  bool f = true;
  if(a[q][p] == '1') return false;

  if(p == 0){
    if(a[q][p+1] == '1') f = false;
  } else if(p == n-2){
    if(a[q][p-1] == '1') f = false;
  } else {
    if(a[q][p-1] == '1' || a[q][p+1] == '1') f = false;
  }

  return f;
}

int main()
{
  while(cin>>n && n){
    cin >> st >> gl >> h;
    st--;
    gl--;

    for(int i = 0; i < h; i++)
      for(int j = 0; j < n-1; j++)
	cin >> a[i][j];

    if(dfs(st, 0)){
      cout << 0 << endl;
      continue;
    }

    bool f = true;
    for(int i = 0; i < h && f; i++)
      for(int j = 0; j < n-1 && f; j++)
	if(check(i, j)){
	  a[i][j] = '1';
	  if(dfs(st, 0)){
	    cout << (i+1) << " " << (j+1) << endl;
	    f = false;
	  }
	  a[i][j] = '0';
	}

    if(f) cout << 1 << endl;
  }

  return 0;
}