{"raw_statement":[{"iden":"statement","content":"Alice and Bob are playing _Luzhanqi_. Each of them has a _permutation_ of the following $24$ pieces: \n\nThe first line contains one integer $T$ denoting the number of test cases ($1 <= T <= 100$).\n\nEach of the next $T$ lines contains $24$ integers denoting Alice's permutation: \n\nOutput one line for each test case.\n\nIf Bob cannot construct the required permutation, print $-1$.\n\nOtherwise, print $24$ integers representing Bob's permutation in the same format as in the input. If there are multiple solutions, print any. Bob's permutation must contain exactly the $24$ pieces described in the statement.\n\nNote that the sample input and sample output contain wrapped lines to fit in the width of page.\n\n"},{"iden":"input","content":"The first line contains one integer $T$ denoting the number of test cases ($1 <= T <= 100$).Each of the next $T$ lines contains $24$ integers denoting Alice's permutation:   $40$ represents Field Marshal  $39$ represents General  $38$ represents Major Generals  $37$ represents Brigadier Generals  $36$ represents Colonels  $35$ represents Majors  $34$ represents Captains  $33$ represents Lieutenants  $32$ represents Engineers  $31$ represents Landmines  $30$ represents Bombs  It is guaranteed that all permutations are chosen uniformly at random and contains exactly the $24$ pieces described in the statement."},{"iden":"output","content":"Output one line for each test case.If Bob cannot construct the required permutation, print $-1$.Otherwise, print $24$ integers representing Bob's permutation in the same format as in the input. If there are multiple solutions, print any. Bob's permutation must contain exactly the $24$ pieces described in the statement."},{"iden":"note","content":"Note that the sample input and sample output contain wrapped lines to fit in the width of page."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nLet $ A = (a_1, a_2, \\dots, a_{24}) $ be a permutation of the multiset $ \\{1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8\\} $, representing Alice's pieces.  \n\n**Constraints**  \n1. $ 1 \\leq T \\leq 100 $  \n2. For each test case, $ A $ is a permutation of the multiset $ \\{1^3, 2^3, 3^3, 4^3, 5^3, 6^3, 7^3, 8^3\\} $ (each integer from 1 to 8 appears exactly three times).  \n\n**Objective**  \nFor each test case, find a permutation $ B = (b_1, b_2, \\dots, b_{24}) $ of the same multiset such that $ b_i \\neq a_i $ for all $ i \\in \\{1, \\dots, 24\\} $.  \nIf no such $ B $ exists, output $ -1 $.  \nOtherwise, output any valid $ B $.","simple_statement":"Alice and Bob play Luzhanqi. Each has a permutation of 24 pieces. Given Alice’s permutation, find any valid permutation for Bob such that no piece is in the same position as Alice’s. If impossible, output -1.","has_page_source":false}