eutral Tonality SOlution Codeforces
You are given an arrayconsisting of integers, as well as an array consisting of integers.
Letdenote the length of theof array . For example, = , = , = .
You need to insert the numbers minimize .into the array , at any positions, in any order. Let the resulting array be . You need to choose the positions for insertion in order to
Formally, you need to find an arraythat simultaneously satisfies the following conditions:
- The array is a subsequence of the array .
- The array consists of the numbers , possibly rearranged.
- The value of minimum possible among all suitable arrays . is the
Each test contains multiple test cases. The first line contains a single integer— the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers— the length of array and the length of array .
The second line of each test case containsintegers — the elements of the array .
The third line of each test case containsintegers — the elements of the array .
It is guaranteed that the sum ofover all test cases does not exceed , and the sum of over all test cases does not exceed .
For each test case, outputnumbers — the elements of the final array , obtained after the insertion, such that the value of is minimized. If there are several answers, you can output any of them.
6 5 4 1 1 7 7 2 2 4 4 5 5 9 8 7 7 6 5 4 3 2 1 1 3 5 2 4 1 9 2 3 8 8 1 4 4 7 7 2 9 6 5 2 2 1 777 1 1 1 1 1 1
In the first test case,. We can insert the number between and , then .
In the second test case,= . After the insertion, . It is easy to see that . It can be shown that it is impossible to achieve less than .