CF BUDDY
← Problems·

1407C · Chocolate Bunny

1600 · constructive algorithms, interactive, math

Problem: This is an interactive problem.

We hid from you a permutation pp of length nn, consisting of the elements from 11 to nn. You want to guess it. To do that, you can give us 2 different indices ii and jj, and we will reply with pimodpjp_{i} \bmod p_{j} (remainder of division pip_{i} by pjp_{j}).

We have enough patience to answer at most 2n2 \cdot n queries, so you should fit in this constraint. Can you do it?

As a reminder, a permutation of length nn is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array) and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array).

Input Format: The only line of the input contains a single integer nn (1n1041 \le n \le 10^4) — length of the permutation.

Sample Cases

Case 1

Input

3

1

2

1

0

Output

? 1 2

? 3 2

? 1 3

? 2 1

! 1 3 2

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