CF BUDDY
← Problems·

1867E1 · Salyg1n and Array (simple version)

2000 · constructive algorithms, interactive, math

Problem: This is the simple version of the problem. The only difference between the versions is the limit on the number of queries. In this version, you can make no more than 100 queries. You can make hacks only if both versions of the problem are solved.

This is an interactive problem!

salyg1n has given you a positive integer kk and wants to play a game with you. He has chosen an array of nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \leq a_i \leq 10^9). You must print a1a2ana_1 \oplus a_2 \oplus \ldots \oplus a_n, where \oplus denotes the bitwise XOR operation. You can make queries of the following type:

  • ?? ii: in response to this query, you will receive aiai+1ai+k1a_i \oplus a_{i + 1} \oplus \ldots \oplus a_{i + k - 1}. Also, after this query, the subarray ai,ai+1,,ai+k1a_i, a_{i + 1}, \ldots, a_{i + k - 1} will be reversed, i.e., the chosen array aa will become: a1,a2,ai1,ai+k1,ai+k2,,ai+1,ai,ai+k,,ana_1, a_2, \ldots a_{i - 1}, a_{i + k - 1}, a_{i + k - 2}, \ldots, a_{i + 1}, a_i, a_{i + k}, \ldots, a_n.

You can make no more than 100100 queries to answer the problem.

Input Format: The first line contains a single integer tt (1t10001 \leq t \leq 1000) – the number of test cases.

Note: In the first test case, the jury has chosen the array aa == [4,2,5,1][4, 2, 5, 1]

In the second test case, the jury has chosen the array aa == [5,7,1,3,3,7][5, 7, 1, 3, 3, 7]

Sample Cases

Case 1

Input

2
4 2

6

4

6 6

4

Output

? 1

? 3

! 2

? 1

! 4

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback