import Data.List

main = interact $ unlines . map drawing_lots_2 . read' . takeWhile (/="0") . lines
 where
  read' [] = []
  read' (n:m:s:d:xs) = (read n, read m, read s, read d, map obstruct (take (read d) xs)) : read' (drop (read d) xs)
  obstruct line = "0" ++ line ++ "0"

drawing_lots_2 (n,m,s,d,amida)
 | reachable m s amida = "0"
 | null right_draws = "1"
 | otherwise = let (l,c) = head right_draws in show l ++ " " ++ show c
 where
  right_draws = [(l,c)| l<-[1..d], c<-[1..(n-1)], reachable m s (draw (l,c) amida),
                        amida!!(l-1)!!(c-1)=='0', amida!!(l-1)!!c=='0', amida!!(l-1)!!(c+1)=='0']
  draw (l,c) amida = take (l-1) amida ++ [update (amida!!(l-1))] ++ drop l amida
   where update line = take c line ++ "1" ++ drop (c+1) line

reachable top bot amida = pursue amida top == bot
 where
  pursue [] col = col
  pursue (l:ls) col
   | l !! col     == '1' = pursue ls (col+1)
   | l !! (col-1) == '1' = pursue ls (col-1)
   | otherwise = pursue ls col