Let $$$p$$$ be an array, initially a permutation$$$^{\text{∗}}$$$ of the integers from $$$1$$$ to $$$n$$$. An array-processing machine produces a sequence $$$s$$$ by repeating the following steps exactly $$$n-1$$$ times:
The process stops when a single element remains in $$$p$$$.
You are given a sequence $$$s$$$ of $$$n-1$$$ integers. Determine whether some initial permutation of length $$$n$$$ produces exactly $$$s$$$. If one exists, construct any such permutation; otherwise, report that it is impossible.
$$$^{\text{∗}}$$$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]$$$ is not a permutation, and $$$[1,3,4]$$$ is also not a permutation.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the length of the initial permutation.
The second line contains $$$n-1$$$ integers $$$s_1, s_2, \ldots, s_{n-1}$$$ ($$$1 \le s_i \le n$$$) — the elements of the sequence $$$s$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, print $$$n$$$ space-separated integers — any permutation of length $$$n$$$ that the machine turns into $$$s$$$. If several such permutations exist, print any of them. If none exists, print -1.
263 5 4 6 221
6 2 5 4 1 3-1
In the first test case, one valid initial permutation is $$$[6, 2, 5, 4, 1, 3]$$$. The machine processes it as follows, with the removed peak shown in bold:
This yields $$$s = [3, 5, 4, 6, 2]$$$.
In the second test case, no valid permutation of length $$$2$$$ can produce $$$s= [1]$$$.
| Name |
|---|


