interactive-gcd-xor#12469

interactive-gcd-xor

1 second
256 megabytes
Very hard

There are two hidden integers 1\le a<b<10^9 such that a and b have no prime divisors p>5000. You may ask queries of the following type: '? ', 1\le c\le 10^{9}. The interactor will then return \gcd(a,c) \oplus \gcd(b,c), where denotes the binary xor-operation. You need to find the \mathrm{lcm}(a,b).

You may ask up to 1337 queries.

The of two integers and is the greatest integer such that divides both and . The of two integers and is the smallest positive integer such that both and divide .

Interaction

You may ask queries of the following type: '? ', 1\le c\le 10^{9}. The interactor will then return \gcd(a,c) \oplus \gcd(b,c).

Once you have determined the answer , output it by printing '! '.

Do not forget to flush the output after each query and after giving the answer using fflush(stdout) in C++ or sys.stdout.flush() in python.

Examples

Example 1

Loading
Loading

Note

The hidden integers in the sample are 4 and 6.

After the first query, the interactor returns \gcd(4,1) \oplus \gcd(6,1)=1 \oplus 1 =0.

In the third query, the program than asks ? 67 to which the interactor returns 0.

Finally after all queries are made, the program correctly outputs 12, since \mathrm{lcm}(6,4)=12.

Scoring

Subtask : (a=1) ( points)

Subtask : (a=k^x, b=k^y) for some k,x,y \in \mathbb{Z}, k\ge 1, x,y \ge 0 ( points)

Subtask : No additional constraints ( points)