Guess the tree
This is an interactive problem.
After the great battle that destroyed the planetary system Link-Cut, the local inhabitants asked you to help restore it. Unfortunately, almost all information about how it looked has disappeared. However, the wizard Frusy has once again come to your aid! He discovered a magical nebula that remembers how the system looked before the battle.
The Link-Cut planetary system can be represented as a tree consisting of vertices. For a single query to the nebula, you can provide a permutation of the tree vertices . In response to the query, you receive an array , where represents the number of connected components in the forest obtained by retaining only the vertices , , , .
Since each query costs Frusy a significant amount of mana, you are allowed to make at most queries.
The interactor is not adaptive!
Input
The first line contains only one numbers .
Interaction
To perform the request, output "?
", where is a permutation.
In response to the request, the jury program will output an array , where each element will be separated with the space.
If the request is invalid (i.e., the maximum number of requests has been exceeded or the request parameters are invalid), the jury program will output -1
and terminate. In this case, terminate your program to receive the verdict Wrong Answer
.
Be sure to call the flush
method after outputting each line. You can use:
fflush(stdout)
,cout << endl
, orcout.flush()
inC++
;System.out.flush()
inJava
;flush(output)
inPascal
;sys.stdout.flush()
inPython
;consult the documentation for other programming languages.
Output
To give the answer, output in the first line "!
", and in the next lines an edge, represented by two integers and , of the tree in any order.
Examples
5 1 1 1 1 1 1 2 3 3 1
? 1 2 3 4 5 ? 4 5 1 2 3 ! 1 2 4 3 3 1 3 5
Note
This image corresponds to the second query and a prefix of length . We have highlighted the vertices , resulting in connected components.
Scoring
( points): , ;
( points): , ;
( points): , ;
( points): , ;
( points): The tree is a bamboo (each vertex has at most two neighbors), ;
( points): ;
( points): ;