时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld
题目描述
Alice and Bob are playing

. Each of them has a

of the following

pieces:
- one Field Marshal, order 9
- one General, order 8
- two Major Generals, order 7
- two Brigadier Generals, order 6
- two Colonels, order 5
- two Majors, order 4
- three Captains, order 3
- three Lieutenants, order 2
- three Engineers, order 1
- two Bombs
- three Landmines
To determine the winner, we repeat the following process until someone wins the game or the game ends in a draw:
- If both permutations are empty, the game ends in a draw.
- If Alice's permutation is empty, Bob wins the game.
- If Bob's permutation is empty, Alice wins the game.
- Let the first piece in Alice's permutation be
and the first piece in Bob's permutation be
. The following is the outcome of the battle between
and
:
- If
and
are the same types of pieces, or if one of
and
is Bomb, they are both removed. - Otherwise, if one of
and
is Landmine and the other is Engineer, the Landmine is removed and the Engineer stays alive. - Otherwise, if one of
and
is Landmine and the other's order is greater than 1, the Landmine stays alive and the other one is removed. - Otherwise, we compare the order of
and
and the piece with smaller order is removed.
Bob knows Alice's permutation in advance and can decide his permutation based on that information. After Bob deciding his permutation, Alice can swap two pieces in Bob's permutation. Can Bob construct a permutation that wins against Alice's permutation no matter which pair of pieces she swaps?
输入描述:
The first line contains one integer
denoting the number of test cases (
).
Each of the next
lines contains
integers denoting Alice's permutation:
•
represents Field Marshal
•
represents General
•
represents Major Generals
•
represents Brigadier Generals
•
represents Colonels
•
represents Majors
•
represents Captains
•
represents Lieutenants
•
represents Engineers
•
represents Landmines
•
represents Bombs
It is guaranteed that all permutations are chosen uniformly at random and contains exactly the
pieces described in the statement.
输出描述:
Output one line for each test case.
If Bob cannot construct the required permutation, print
.
Otherwise, print
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
pieces described in the statement.
示例1
输入
复制
4
40 39 38 38 37 37 36 36 35 35 34 34 34 33 33 33 32 32 32 31 31 31 30 30
34 31 36 33 31 39 37 38 35 32 32 35 36 31 34 32 38 40 30 33 30 34 33 37
37 30 40 38 36 38 32 34 36 35 37 32 34 33 31 30 33 31 35 34 33 39 31 32
30 33 32 39 37 38 35 40 34 30 31 37 31 33 31 33 34 32 36 36 35 34 32 38
输出
复制
34 36 30 39 33 38 37 31 34 30 33 35
38 31 37 33 40 31 35 32 32 36 32 34
34 32 32 38 40 33 33 30 31 34 31 35
37 32 34 36 33 31 38 30 36 37 35 39
38 33 32 31 36 34 30 34 33 40 32 37
38 30 37 35 33 35 32 31 34 31 39 36
37 34 33 36 34 35 31 38 32 38 31 32
37 30 30 31 33 36 32 33 40 39 34 35