(define (output-solution p q) (begin (display "! ") (display p) (display " ") (display q) (newline) (flush))) (define n (read)) (define (itr a) (let1 b (gcd n a) (if (not (= b 1)) (output-solution b (/ n b)) (begin (display "? ") (display a) (newline) (flush) (let1 r (read) (if (odd? r) (itr (+ a 1)) (let1 x (expt-mod a (/ r 2) n) (if (= x (- n 1)) (itr (+ a 1)) (let1 p (gcd n (+ x 1)) (output-solution p (/ n p))))))))))) (itr 2)