#P13943. [EC Final 2019] Game

[EC Final 2019] Game

题目描述

Alice and Bob are playing Luzhanqi\textit{Luzhanqi}. Each of them has a permutation\textit{permutation} of the following 2424 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 AA and the first piece in Bob's permutation be BB. The following is the outcome of the battle between AA and BB: -If AA and BB are the same types of pieces, or if one of AA and BB is Bomb, they are both removed.
  • Otherwise, if one of AA and BB is Landmine and the other is Engineer, the Landmine is removed and the Engineer stays alive.
  • Otherwise, if one of AA and BB 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 AA and BB 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 TT denoting the number of test cases (1T1001\le T\le 100).

Each of the next TT lines contains 2424 integers denoting Alice's permutation:

  • 4040 represents Field Marshal
  • 3939 represents General
  • 3838 represents Major Generals
  • 3737 represents Brigadier Generals
  • 3636 represents Colonels
  • 3535 represents Majors
  • 3434 represents Captains
  • 3333 represents Lieutenants
  • 3232 represents Engineers
  • 3131 represents Landmines
  • 3030 represents Bombs

It is guaranteed that all permutations are chosen uniformly at random and contains exactly the 2424 pieces described in the statement.

输出格式

Output one line for each test case.

If Bob cannot construct the required permutation, print 1-1.

Otherwise, print 2424 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 2424 pieces described in the statement.

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 39 35 38 33 34 36 31 37 31 32 37 33 33 35 32 36 38 31 32 30 40 30 34
35 30 32 33 33 38 32 31 35 33 31 37 36 31 39 30 34 32 40 36 34 34 37 38
36 39 34 38 34 32 33 33 30 31 37 33 40 32 34 36 30 32 38 35 31 31 35 37
36 35 34 39 40 33 31 37 31 30 32 38 30 33 33 34 32 34 35 37 36 32 38 31