def class_div(a,n,m,f) if f then 1.upto(n) do |i| a << i end else n.downto(1) do |i| a << i end end if a.size >= m then a elsif f then class_div(a,n,m,false) else class_div(a,n,m,true) end end students, classes = gets.split.map(&:to_i) hanako, taro = gets.split.map(&:to_i) max = hanako > taro ? hanako : taro arr = [] arr = class_div(arr, classes, max, true) if arr[hanako-1] == arr[taro-1] then puts "YES" else puts "NO" end