#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n,d,m,g;
int a[30][10];

bool solve(){
  int x=m-1;
  rep(i,d){
    if(x>0&&a[i][x-1])x--;
    else if(x<n-1&&a[i][x])x++;
  }
  return x==g-1;
}

void run(){
  while(cin>>n,n){
    cin>>m>>g>>d;
    MEMSET(a);
    char c;
    rep(i,d){
      rep(j,n-1){
	cin>>c;
	a[i][j]=c-'0';
      }
    }
    if(solve()){
      cout<<0<<endl;
      continue;
    }
    rep(i,d){
      rep(j,n-1){
	if(a[i][j])continue;
	if(j>0&&a[i][j-1])continue;
	if(j<n-1&&a[i][j+1])continue;
	a[i][j]=1;
	if(solve()){
	  cout<<(i+1)<<" "<<(j+1)<<endl;
	  goto BR;
	}
	a[i][j]=0;
      }
    }
    cout<<1<<endl;
  BR:;
  }
}

