#P1893B. Neutral Tonality
Neutral Tonality
Description
You are given an array consisting of integers, as well as an array consisting of integers.
Let denote the length of the longest increasing subsequence of array . For example, = , = , = .
You need to insert the numbers 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 minimize .
Formally, you need to find an array that simultaneously satisfies the following conditions:
- The array is a subsequence of the array .
- The array consists of the numbers , possibly rearranged.
- The value of is the minimum possible among all suitable arrays .
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 contains integers — the elements of the array .
The third line of each test case contains integers — the elements of the array .
It is guaranteed that the sum of over all test cases does not exceed , and the sum of over all test cases does not exceed .
For each test case, output numbers — 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.
Input
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 contains integers — the elements of the array .
The third line of each test case contains integers — the elements of the array .
It is guaranteed that the sum of over all test cases does not exceed , and the sum of over all test cases does not exceed .
Output
For each test case, output numbers — 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.
Note
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 .