#include<iostream>
#include<algorithm>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 31
using namespace std;
int n,m,goal,d;
bool G[MAX][MAX];

bool check()
{
  int ps[n];
  rep(i,n)ps[i] = i;


  rep(i,d)
    rep(j,n-1)
      if(G[i][j])
	  swap(ps[j],ps[j+1]);

  rep(i,n)
    if(ps[i] == m)
      return i == goal;
  assert(false); 
}

void compute()
{
  rep(i,d)
    {
      rep(j,n-1)
	{
	  if(G[i][j] || (i-1 >= 0 && G[i][j-1]) || G[i][j+1])continue;
	  G[i][j] = true;
	  if(check())
	    {
	      cout << i+1 << " " << j+1 << endl;
	      return;
	    }
	  G[i][j] = false;
	}
    }
  cout << 1 << endl;
}

void print()
{
  rep(i,d)
    {
      rep(j,n-1)
	{
	  cout << G[i][j];
	}
      cout << endl;
    }
      cout << endl;
}

int main()
{
  while(cin >> n,n)
    {
      cin >> m >> goal >> d;
      m--,goal--;
      {
	char c;
	rep(i,d)
	  rep(j,n-1)
	  {
	    cin >> c;
	    G[i][j] = c-'0';
	  }	    
      }

      if(check())
	{
	  cout << 0 << endl;
	  goto Skip;
	}

      compute();

    Skip:;

    }
  return 0;
}