$n, $m = gets.chomp.split(' ').map{|i| i.to_i(10)} $x, $y = gets.chomp.split(' ').map{|i| i.to_i(10)} def find_class (x, m, n) x -= 1 d = (x / m) & 1 if d == 0 then (x % m) + 1 else m - (x % m) end end a = find_class($x, $m, $n) b = find_class($y, $m, $n) if a == b then puts "YES" else puts "NO" end