You are given a connected simple undirected graph with an even number of vertices. The vertices are numbered from to .
The interactor has chosen a hidden perfect matching consisting of edges of . Thus, contains exactly edges, and every vertex belongs to exactly one of them.
You may ask about a spanning tree of . For this query, the interactor returns
where is the number of edges on the unique path between and in .
Your task is to determine the exact hidden matching . The graph may have several perfect matchings; outputting a perfect matching different from is not accepted.
You may make at most queries.
To ask a query, print a line containing ?, followed by lines describing the edges of a spanning tree of the given graph:
Every printed edge must belong to the given graph, and the printed edges must form a spanning tree. The interactor replies with one integer: the sum of the distances between the endpoints of all hidden matching edges in this tree.
When you have determined the hidden matching, print a line containing !, followed by its edges:
The matching edges may be printed in any order, and the endpoints of each edge may be printed in either order.
After every query, flush the output buffer. If you read at any point, terminate your program immediately. After printing the final answer, terminate without reading another response.
The participant queries the path . The hidden pairs have distances and , so the interactor returns . The participant then reports the hidden matching.
For the queried path, the three hidden pairs have distances , , and . Therefore, the interactor returns .