loop do
  n, m, a, d = 4.times.map{ gets.to_i }
  break if n == 0
  bar = d.times.map{ gets.chomp.split('').map(&:to_i) }
  goal = Array.new(n){|i| i}
  can = n.times.map{ [false]*n }
  (d-1).downto(0) do |i|
    (n-1).times do |j|
      if bar[i][j] == 1
        goal[j], goal[j+1] = goal[j+1], goal[j]
      else
        if (bar[i][j-1] == 0 || j == 0) && (bar[i][j+1] == 0 || j == n-2)
          can[goal[j]][goal[j+1]] = can[goal[j+1]][goal[j]] = [i, j]
        end
      end
    end
  end
  if goal[m-1] == a-1 then p 0
  else
    if ret = can[a-1][goal[m-1]]
      puts "#{ret[0]+1} #{ret[1]+1}"
    else p 1
    end
  end
end