import math;n=int(input());P=lambda p:0 if(g:=math.gcd(p,n))<3 or g==n else[print("!",g,n//g),exit()];P(3);[[P(a),print("?",a),r:=int(input()),[P(pow(a+b,r//(2-(r&1)),n)-1)for b in range(99)]]for a in range(2,n)]