import scala.io.StdIn.{readInt,readLine}

object Main {
  def swap(a:Array[Int], i:Int, j:Int) = {
    val temp = a(i)
    a(i) = a(j)
    a(j) = temp
  }

  def canDraw(str:String, i:Int):Boolean =
    if( str.length==1 || (i==0 && str.length > 1 && str(i+1)!='1') || (i>0 && i==str.length-1 && str(i-1)!='1') ||
      (i>0 && i<str.length-1 && str(i+1)!='1' && str(i-1)!='1') ) true
    else false

  def scan(l:Array[Int], m:Int, x:Int, d:Int, s:Array[String],line:Int,pos:Int):String = {
    if(line == d) "1"
    else {
      val lots = l.clone
      var result = ""
      if(line == -1) {
        for(i<-0 until d) {
          for(j<-0 until s(i).length)
            if(s(i)(j)=='1') swap(lots,j,j+1)
        }
        if(lots(x-1) == m) result ="0"
      } else if(canDraw(s(line),pos) ) {
        for(i<-0 until d) {
          for(j<-0 until s(i).length) {
            if(s(i)(j)=='1') {
              swap(lots,j,j+1)
            } else {
              if(line==i && j==pos) {
                swap(lots,j,j+1)
              }
            }
          }
        }
        if(lots(x-1) == m) result = (line+1) + " " + (pos+1)
      }

      if(result == "") {
        if(pos >= s(0).length-1) scan(l,m,x,d,s,line+1,0)
        else scan(l,m,x,d,s,line,pos+1)
      } else {
        result
      }
    }
  }

  def main(args:Array[String]) = {
    Iterator.continually(readLine).takeWhile(_.trim!="0").foreach { s =>
      val n = s.toInt
      val (m,x,d) = (readLine.trim.toInt,readLine.trim.toInt,readLine.trim.toInt)
      val lots = (1 to n).toArray

      val list = for(i<-1 to d) yield readLine.trim
      println(scan(lots,m,x,d,list.toArray,-1, 0))
    }
  }
}