Joy with Permutations

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

문제

This is an interactive 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 questions to identify this permutation. 

He may ask questions of two types:

  • Type 1, formatted as "? 1 i j k": Bob chooses three different integers ii, jj, kk (1i,j,kN1 \le i, j, k \le N), Alice 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).
  • Type 2, formatted as "? 2 i j": Bob chooses two different integers ii, jj (1i,jN1 \le i, j \le N), and Alice answers ii if a_i<a_ja\_i < a\_j, or jj otherwise.

The game seems to be too easy for Bob, so Alice invented new rules. First, Bob may ask only 2N2 N questions of type 1 and only 22 questions of type 2. Second, Alice may change the permutation freely as long as it is consistent with all answers that were given before.

Help Bob to win and write the program that identifies the permutation.