单点时限: 2.0 sec
内存限制: 512 MB
John has learned data structure and algorithm course this semester, and he has a problem in the latest problemset that he desperately needs your help.
Given a permutation
Each adjustment specifies a index
Your task is to find the final permutation after
There are multiple test cases in this problem, and the input of each test case are as following statement:
In the first line of each test case, there are two integers
In the second line of each test case, there is a permutation
And in the last line of each test case, there are
It is guaranteed that the sum of
For each test case, output one line which contains
5 3 1 2 3 4 5 3 2 1 6 2 2 3 4 5 6 1 3 4
4 5 1 2 3 1 2 3 4 5 6