Lazy Judge

아직 제출이 없습니다시간 제한15초메모리 제한512 MB

문제

This is an interactive problem.

The judges are working on the strategy for the jury program for the modified version of the problem J from the current contest.

In that problem, Alice secretly invents a permutation of first NN integers a_1,a_2,a_Na\_1, a\_2, \ldots a\_N and tells NN to Bob.

Bob asks some questions to identify this permutation. Alice may change the permutation in the process as long as it is consistent with her previous answers.

The judges are planning to create an AliceBot that will do the following.

There are two phases: the question phase and the answer phase.

In the question phase, the judge tells to AliceBot an integer NN. Then AliceBot has to answer some questions the judge asks about the permutation.

In the subsequent answer phase, AliceBot must compose two different permutations a_1,,a_Na\_1, \ldots, a\_N and b_1,,b_Nb\_1, \ldots, b\_N that are consistent with the answers from the previous phase.

The judge who asks questions has an initial patience P=2NP = 2N. Each time the judge asks a question, the judge's patience decreases.

There are three types of questions the judge can ask:

\begin{itemize} \item Type 1, formatted as "? 1 i j k": the judge chooses three different integers ii, jj, kk (1i,j,kN1 \le i, j, k \le N), AliceBot looks at the three integers a_ia\_i, a_ja\_j, and a_ka\_k, and tells Bob the value of their median (the one that is neither minimum nor maximum). Each such question decreases the judge's patience by 2.

\item Type 2, formatted as "? 2 i j": the judge chooses two different integers ii, jj (1i,jN1 \le i, j \le N), and AliceBot answers ii if a_i<a_ja\_i < a\_j, or jj otherwise. Each such question decreases the judge's patience by 2.

\item Type 3, formatted as "? 3 i j": the judge chooses two different integers ii, jj (1i,jN1 \le i, j \le N), and AliceBot tells the minimum value among a_ia\_i and a_ja\_j. Each such question decreases the judge's patience by 1. \end{itemize}

You may assume that judge's patience will be strictly greater than 2 after asking a question. When the judge decides that they asked enough questions, the command "!" is sent to the AliceBot, switching it to the answer phase.

In the answer phase, AliceBot tells the judge two permutations a_1,,a_Na\_1, \ldots, a\_N and b_1,,b_Nb\_1, \ldots, b\_N. These two permutations must be consistent with all the answers given in the question phase, and the number of positions ii such that a_ib_ia\_i \ne b\_i has to be at least p/2\lceil p / 2 \rceil, where pp is the judge's patience at the end of the question phase.

Because the judge is too lazy, you are asked to implement the AliceBot. It can be shown that the problem is solvable for every possible NN from the constraints.