input_line = gets.chomp!.to_i questions = [] for i in 1..input_line input_line2 = gets.chomp!.split(' ').map{|n| n.to_i} questions.push(input_line2) end questions.each do |input_line2| good_points = [] for i in 0..input_line2[0] point = [] point.push(i) point.push(input_line2[0] - i) good_points.push(point) point2 = point.dup point2[0] = point2[0] * -1 if (!good_points.include?(point2)) then good_points.push(point2) end point3 = point2.dup point3[1] = point3[1] * -1 if (!good_points.include?(point3)) then good_points.push(point3) end point4 = point3.dup point4[0] = point4[0] * -1 if (!good_points.include?(point4)) then good_points.push(point4) end end distances = [] good_points.each do |point| distance = Math.sqrt((point[0] - 0)**2 + (point[1] - 0)**2) distances.push(distance) end if (distances.length < input_line2[1]) then puts 'No' else puts 'Yes' serach = distances.sort[input_line2[1] - 1] index = distances.index(serach) target_point = good_points[index] puts target_point.join(' ') end end