单点时限: 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 $a_1,a_2,\cdots,a_n$ of $1, 2,\cdots, n$, and the position of the elements will be adjusted $m$ times.
Each adjustment specifies a index $k$, which means to adjust the array with following operation:
Your task is to find the final permutation after $m$ operations.
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 $n$ and $m$ ($1\leq n,m\leq 10^5$) , representing the number of elements in the array and the adjustment times correspondingly.
In the second line of each test case, there is a permutation $a_1,a_2,\cdots,a_n$ of $1, 2,\cdots, n$, representing the original permutation.
And in the last line of each test case, there are $m$ integers, representing the index $k(1\leq k\leq n)$ of each adjustment.
It is guaranteed that the sum of $n$ over all test cases does not exceed $2\times 10^5$, and the sum of $m$ over all test cases also does not exceed $2\times 10^5$.
For each test case, output one line which contains $n$ integers (separated by a space), representing the final permutation after $m$ operations.
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