x,y = gets.split.map(&:to_i) if (x.abs >= 7 || y.abs >= 7) then puts "NO" return end q = Array.new() gone = Array.new() xjump=[1,1,-1,-1,2,2,-2,-2] yjump=[2,-2,2,-2,1,-1,1,-1] cp = [0,0] #current_position q.push(cp) gone.push(cp) while q cp = q.shift if cp == [x,y] then puts "YES" return else gone.push(cp) for i in (0..7) np = [ cp[0] + xjump[i] , cp[1] + yjump[i] ] #next_position unless gone.include?(np) then q.push(np) gone.push(np) end end end end