Problem: This is an interactive problem.
There is a hidden permutation .
Consider an undirected graph with nodes only with no edges. You can make two types of queries:
- Specify an integer satisfying . For all integers () such that , an edge between node and node will be added.
- Query the number of edges in the shortest path between node and node . As the answer to this question you will get the number of edges in the shortest path if such a path exists, or if there is no such path.
Note that you can make both types of queries in any order.
Within queries (including type and type ), guess two possible permutations, at least one of which is . You get accepted if at least one of the permutations is correct. You are allowed to guess the same permutation twice.
A permutation of length is an array consisting of distinct integers from to in arbitrary order. For example, is a permutation, but is not a permutation ( appears twice in the array), and is also not a permutation ( but there is in the array).
Input Format: Each test contains multiple test cases. The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of the permutation.
It is guaranteed that the sum of over all test cases does not exceed .
Note: In the first test case, and the hidden permutation .
Firstly, make a type query on respectively. This adds four edges to the graph in total:
- An edge that connects node and node .
- An edge that connects node and node .
- An edge that connects node and node .
- An edge that connects node and node .
Since all of these queries are valid, the interactor returns after each of them.
Then, query the number of edges in the shortest path between node and , which is equal to .
Then, make a type query on . This adds four edges to the graph in total:
- An edge that connects node and node .
- An edge that connects node and node .
- An edge that connects node and node .
- An edge that connects node and node .
Since this query is valid, the interactor returns .
Then, query the number of edges in the shortest path between node and , which is equal to .
Then, query the number of edges in the shortest path between node and . Such a path doesn't exist, therefore the interactor returns .
Afterwards, due to some magic, two possible permutations that can be are determined: the first permutation is and the second permutation is . Since the first permutation is equal to the hidden permutation, this test case is solved correctly. In total, queries are used, which is within the limit of queries.
Since the answer is correct, the interactor returns .
In the second test case, and the hidden permutation is .
Since there are only possible permutations, no queries are needed. It is sufficient to just output the two permutations, and . In total, queries are used, which is within the limit of queries.
Since the answer is correct, the interactor returns .