#include<iostream>
using namespace std;int n,m,g,d,l[10],f,i,j,y,x;string p[30];int c(){for(y=n;y-->0;)l[y]=y+1;for(;++y<d;)for(x=n-1;x-->0;)if(p[y][x]^48)swap(l[x],l[x+1]);return l[g-1]==m;}Main(){for(;cin>>n>>m>>g>>d;f-1?puts(f?"0":"1"):printf("%d %d\n",i,j)){for(i=0;i<d;)cin>>p[i++];f=c()*2;for(i=0;!f & i<d;i++)for(j=0;!f & j<n-1;j++)if(p[i][j]-49&p[i][j-1]-49&p[i][j+1]-49){p[i][j]++,f=c(),p[i][j]--;};}}