| Codeforces Round 1076 (Div. 3) |
|---|
| Finished |
A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ and $$$[1,3,4]$$$ are not permutations.
You are given a permutation $$$p$$$ of length $$$n$$$. You can perform the following operation exactly once:
Each test consists of several test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows.
The first line of each test case contains the number $$$n$$$ ($$$1\le n\le 2\cdot 10^5$$$).
The second line of each test case contains $$$n$$$ distinct integers $$$p_1, p_2,...,p_n$$$ $$$(1\le p_i\le n)$$$.
It is guaranteed that the sum of the values of $$$n$$$ across all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output the lexicographically maximum permutation that can be obtained with one operation.
443 2 1 433 1 244 3 2 122 1
4 1 2 33 2 14 3 2 12 1
For the first test case, the best segment is $$$[1, 4]$$$. After reversing, $$$a = [4, 1, 2, 3]$$$. For the second test case, the best segment is $$$[2, 3]$$$. After reversing, $$$a = [3, 2, 1]$$$.
| Name |
|---|


