eval"N,V,X,Y="+gets.split*?, L=$<.map{|s|s.split.map(&:to_i)+M=[1e3]}+[M*N] d={k=[0,0,1]=>V} q=[[V]+k] while(h,x,y,o=q.pop) x+y>N*2-3&&$><<:YES|exit [x,y,o]==[X-1,Y-1,1]&&(h*=2;o=0) [[x+1,y],[x,y+1],[x-1,y],[x,y-1]].map{|a,b|(0e}||q.size,0]=[e])}end $><<:NO