#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,m,a,d;
char b[33][9];

int go(){
	int c=m-1;
	rep(i,d){cout<<c<<" ";
		if(c>0&&b[i][c-1]=='1')c--;
		else if(c<n-1&&b[i][c]=='1')c++;
	}
	cout<<c<<endl;
	return c==a-1;
}

int main(){
	while(cin>>n&&n){
		cin>>m>>a>>d;
		rep(i,d)rep(j,n-1)cin>>b[i][j];
		if(go()){cout<<0<<endl;goto nx;}
		rep(i,d)rep(j,n-1){
			if(b[i][j]=='0'&&(j==0||b[i][j-1]=='0')
				&&(j==n-2||b[i][j+1]=='0')){
				b[i][j]='1';
				if(go()){
					cout<<i+1<<" "<<j+1<<endl;
					goto nx;
				}
				b[i][j]='0';
			}
		}
		cout<<1<<endl;
		nx:;
	}
}