#include<iostream>

using namespace std;

int main()
{
	int n,m,d,b,hit,miss;
	char a;
	int ans,a_ans[2];
	int amida[10][31]={0};
	int yoko[9][31];
	int i,j;
	
	for(;;){
		cin >> n;
		if(n==0)
			break;
		cin >> m >> hit >> d ;
		
//		cout  << "input end" << endl;
//		cout << "n:" << n << " m:" << m << " hit:" << hit << " d:" << d << endl;
		ans=-1;
		a_ans[0]=a_ans[1]=-1;
		
		for(i=0;i<n;i++)
			amida[i][0]=i+1;
		
		for(i=0;i<d;i++){
			for(j=0;j<n-1;j++){
				yoko[j][i]=0;
			}
		}
		for(i=0;i<d;i++){
//			cout << "loop:" << i << endl;
			if(i!=0)
				for(j=0;j<n;j++)
					amida[j][i]=amida[j][i-1];
			for(j=1;j<n;j++){
				
				cin >> a ;
				if(a=='1'){
//					cout << "j:" << j << " i:" << i << " a1:" << amida[j][i] << " a2:" << amida[j-1][i] << endl;
					yoko[j-1][i]=1;
					b=amida[j][i];
					amida[j][i]=amida[j-1][i];
					amida[j-1][i]=b;
				}
			}
		}
		
/*/		cout << "loop end" << endl;
		for(i=0;i<d;i++){
			for(j=0;j<n;j++){
				if(j!=n-1)
					cout << amida[j][i] << " " ;
				else
					cout << amida[j][i] << endl;
			}
		}
		cout << "yokodesuyo" << endl;
		for(i=0;i<d;i++){
			for(j=0;j<n-1;j++){
				if(j!=n-2)
					cout << yoko[j][i] << " " ;
				else
					cout << yoko[j][i] << endl;
			}
		}
//*/		
		if(amida[hit-1][d-1]==m){
			ans=0;
		}
/*/		else
			cout << "start:" << m << " hit:" << amida[hit-1][d-1] << endl;
//*/		
		miss=amida[hit-1][d-1];
//		cout << "m:" << m << " miss:" << miss << endl;
		int flag=0;
		
		if(n!=2){
			for(i=1;i<d-1;i++){
				for(j=1;j<n;j++){
	//				cout << "j:" << j << " i:" << i << " a1:" << amida[j][i] << " a2:" << amida[j-1][i] << endl;
					if((amida[j][i]==m && amida[j-1][i]==miss) || (amida[j][i]==miss && amida[j-1][i]==m)){
	//				cout << "!!CHECK!! j:" << j << " i:" << i << " a1:" << amida[j][i] << " a2:" << amida[j-1][i] << endl;
						if(j!=n-1){
	//						cout << "before_ans1 yoko1:" << yoko[j-1][i-1] << " yoko2:" << yoko[j][i-1] << endl;
							if(yoko[j-1][i-1]==0 && yoko[j][i-1]==0){
								a_ans[0]=i-1;
								a_ans[1]=j;
								flag=1;
								break;
							}
						}
						else{
	//						cout << "before_ans2 yoko1:" << yoko[j-1][i-1] << " yoko2:" << yoko[j-2][i-1] << endl;
							if(yoko[j-1][i-1]==0 && yoko[j-2][i-1]==0){
								a_ans[0]=i-1;
								a_ans[1]=j;
								flag=1;
								break;
							}
						}
					}
				}
			}
			for(j=1;j<n;j++){
//				cout << "j:" << j << " i:" << d-1 << " a1:" << amida[j][d-1] << " a2:" << amida[j-1][d-1] << endl;
				if((amida[j][d-1]==m && amida[j-1][d-1]==miss) || (amida[j][d-1]==miss && amida[j-1][d-1]==m)){
//				cout << "!!CHECK!! j:" << j << " i:" << d-1 << " a1:" << amida[j][d-1] << " a2:" << amida[j-1][d-1] << endl;
					if(j!=n-1){
//						cout << "before_ans1 yoko1:" << yoko[j-1][d-1] << " yoko2:" << yoko[j][d-1] << endl;
						if(yoko[j-1][d-1]==0 && yoko[j][i-1]==0){
							a_ans[0]=d;
							a_ans[1]=j;
							flag=1;
							break;
						}
					}
					else{
//						cout << "before_ans2 yoko1:" << yoko[j-1][d-1] << " yoko2:" << yoko[j-2][d-1] << endl;
						if(yoko[j-1][d-1]==0 && yoko[j-2][d-1]==0){
							a_ans[0]=d;
							a_ans[1]=j;
							flag=1;
							break;
						}
					}
				}
			}
		}
		else{
			for(i=0;i<d;i++){
//				cout << "j:" << 0 << " i:" << i << " a1:" << amida[0][i] << endl;
//				cout << "!!CHECK!! j:" << 0 << " i:" << i << " a1:" << amida[0][i] << endl;
//				cout << "before_ans1 yoko1:" << yoko[0][i] << endl;
				if(yoko[0][i]==0){
					a_ans[0]=i+1;
					a_ans[1]=1;
					flag=1;
					break;
				}
			}
		}
		
		
		if(flag==0){
			for(j=1;j<n;j++){
//					cout << "j:" << j << " i:" << 0 << " a1:" << amida[j][0] << " a2:" << amida[j-1][0] << endl;
				if((amida[j][0]==m && amida[j-1][0]==miss) || (amida[j][0]==miss && amida[j-1][0]==m)){
//					cout << "!!CHECK!! j:" << j << " i:" << 0 << " a1:" << amida[j][0] << " a2:" << amida[j-1][0] << endl;
					if(j!=n-1){
//							cout << "before_ans1 yoko1:" << yoko[j-1][0] << " yoko2:" << yoko[j][0] << endl;
						if(yoko[j-1][0]==0 && yoko[j][0]==0){
							a_ans[0]=1;
							a_ans[1]=j;
							break;
						}
					}
					else{
//							cout << "before_ans2 yoko1:" << yoko[j-1][0] << " yoko2:" << yoko[j-2][0] << endl;
						if(yoko[j-1][0]==0 && yoko[j-2][i-1]==0){
							a_ans[0]=1;
							a_ans[1]=j;
							break;
						}
					}
				}
			}
		}

//		cout << "output" << endl;
		if(ans==0)
			cout << "0" << endl;
		else if(a_ans[0]!=-1)
			cout << a_ans[0] << " " << a_ans[1] << endl;
		else
			cout << "1" << endl;
	}
}