Doraemon is planning to clean his pocket and arrange all his gadgets according to a particular order so that he can find the gadgets easily whenever Nobita cries for help!He wasn't able to find his "Sort_Everything" gadget so he asks for your help. He will give you points in return to help you secure rank in the contest.
He will give you two arrays as input. First array contains the ID number of all his gadgets.The second array contains the order in which he wants you to arrange some of his favourite gadgets in the beginning. Then add the remaining gadgets in the sorted order of their ID.
It is possible that gadget ID present in second array might not be present in first array. First array can contain duplicate gadet IDs. no duplicates in the second array is allowed.
Do this for T testcases.
First line contains number of testcases.
Each test case is of 4 lines.
- First line contains the size of the array N
- Second line contains the first array A1 of size N .
- Third line contains the size of the array M
- Fourth line contains the second array, A2 of size M.
It consists of T lines. One line represents the sorted order of the pocket for that test case.
0<T<5
0<N,M<=10^5
0<A1[i], A2[i]<=10^9
Explanation:
Test Case 1:
Here, 7,2 should be placed in this same order at the beginning then remaining in the sorted order
Test Case 2:
Here, only thing to note is that ID 6 is not currently present in Doraemon's pocket. Else all is same.