from math import gcd n=int(input()) a=1 while a1:break print("?",a) r=int(input()) t=pow(a,r//2,n) g=max(gcd(n,t-1)%n,gcd(n,t+1)%n) if g>1:break print("!",g,n//g)