#P1896C. Matching Arrays
Matching Arrays
No submission language available for this problem.
Description
You are given two arrays and of size . The beauty of the arrays and is the number of indices such that .
You are also given an integer . Determine whether it is possible to rearrange the elements of such that the beauty of the arrays becomes . If it is possible, output one valid rearrangement of .
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and (, ) — the size of arrays and and the desired beauty of the arrays.
The second line of each test case contains integers () — the elements of array .
The third line of each test case contains integers () — the elements of array .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output "NO" if it is not possible to rearrange to make the beauty of the arrays equal to .
Otherwise, output "YES". Then, on the next line, output integers which represent the rearrangement of .
If there are multiple solutions, you may output any of them.
You can output "YES" and "NO" in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and (, ) — the size of arrays and and the desired beauty of the arrays.
The second line of each test case contains integers () — the elements of array .
The third line of each test case contains integers () — the elements of array .
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output "NO" if it is not possible to rearrange to make the beauty of the arrays equal to .
Otherwise, output "YES". Then, on the next line, output integers which represent the rearrangement of .
If there are multiple solutions, you may output any of them.
You can output "YES" and "NO" in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
Note
In test cases 1 and 2, the beauty of the arrays has to be since .
In test cases 3, 4, 5 and 6, the only possible beauty of the arrays is and . In particular, if is rearranged to , then , so the beauty of the arrays is . If is kept in the same order as given the input, then and , so the beauty of the arrays is .