n,m = gets.chomp.split(" ").map(&:to_i) #0:未探索 1:探索済み visited = Array.new(n+1){Array.new(n+1,false)} visited[1][1] = true queue = [[1,1]] black = m-2 while queue.empty?.! x,y,z = queue[0] queue.shift next if black < n-x + n-y - 1 [[1,0],[0,1],[-1,0],[0,-1]].each do |dx,dy| nx = x+dx ny = y+dy next if nx < 1 || ny < 1 || n < nx || n < ny next if visited[nx][ny] if nx == n && ny == n puts "Yes" exit end puts "#{nx} #{ny}" $stdout.flush inp = gets.chomp visited[nx][ny] = true if inp == "Black" queue << [nx,ny] black -= 1 end end end puts "No"