def f(d,u) if d==u then puts ["!",d]*" " STDIN.flush else m=(d+u)/2 puts ["?",m]*" " STDIN.flush x=gets.to_i if x==1 then puts ["?",m+1]*" " STDIN.flush if gets.to_i==0 then puts ["!",m]*" " STDIN.flush return end end if x==0 then f(d,m) else f(m+1,u) end end end f(1,10**9)