require 'prime' N = gets.to_i def send_query(z) STDOUT.puts("! #{z}") STDOUT.flush end 1.upto(N) do |n| send_query(n) end