{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eBaoBao has just found an array $A \u003d \\{a_1, a_2, \\dots, a_n\\}$ of $n$ integers in his left pocket. As BaoBao is bored, he decides to rearrange it into another array $B \u003d \\{b_1, b_2, \\dots, b_n\\}$ of $n$ integers such that $B$ is a permutation of $A$, and $a_i \\ne b_i$ for all $1 \\le i \\le n$. Please help BaoBao finish the rearragement.\u003c/p\u003e\n\n\u003cp\u003eIf multiple valid rearrangements exist, find the smallest one among them.\u003c/p\u003e\n\n\u003cp\u003eConsider two arrays $C \u003d \\{c_1, c_2, \\dots, c_n\\}$ and $D \u003d \\{d_1, d_2, \\dots, d_n\\}$, we say $C$ is smaller than $D$ if there exists an integer $k$ such that $1 \\le k \\le n$, $c_i \u003d d_i$ for all $1 \\le i \u0026lt; k$, and $c_k \u0026lt; d_k$.\u003c/p\u003e\n\n\u003ch4\u003eInput\u003c/h4\u003e\n\u003cp\u003eThere are multiple test cases. The first line of the input contains an integer $T$, indicating the number of test cases. For each test case:\u003c/p\u003e\n\n\u003cp\u003eThe first line contains an integer $n$ ($1 \\le n \\le 10^5$), indicating the length of the array.\u003c/p\u003e\n\n\u003cp\u003eThe second line contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le n$), indicating the given array.\u003c/p\u003e\n\n\u003ch4\u003eOutput\u003c/h4\u003e\n\u003cp\u003eFor each test case output one line containing $n$ integers $b_1, b_2, \\dots, b_n$ separated by a space, indicating the answer. If there are multiple valid answers, output the smallest one. If no valid answer exists, print \"Impossible\" (without quotes) instead.\u003c/p\u003e\n\n\u003cp\u003ePlease, DO NOT output extra spaces at the end of each line, or your answer may be considered incorrect!\u003c/p\u003e\n\n\u003ch4\u003eSample\u003c/h4\u003e\n\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\n4\n4 1 3 2\n4\n1 1 2 3\n3\n1 1 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 2 4 3\n2 3 1 1\nImpossible\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n"}}]}