#00013A

z-sorting

Mister Little Z. wrote some nice and fast method for sorting competition results. His method takes all the scores and sorts them in decreasing order.

However, some hackers wanted to mess up with mister Little Z's website, so they hacked his code so that after the sorting is done, some exchanges are made. For example if the sorted array is "4 3 2 1", Hacker's code will transform this list to "4 1 3 2". in this case the following exchanges are made: from position 2 to position 4, then from position 4 to position 3. Note that multiple exchange operations could lead to the same result.



You are given the results of one competition, where all the scores are different. The results are sorted by Little's Z sorting algorithm, and then, hacker's code has exchanged some results. You are also given the scores from the next competition (same number of scores but not sorted at all), your job is to simulate Z's sorting algorithm, and then simulate hacker's algorithm, and predict what will be shown on the website.



InputFrom the first line of the input read one integer N, (1 <= N <= 50000), where N is the number of scores in both competitions. From the second line read N integers (space separated), that represent the sorted and hacked results from the first competitions. Finally from the third line read N integers that represent the scores (not sorted at all) from the second competition. All the scores will be in the range [0, 2000000000].

OutputTo the standard output in one line write N space separated integers, that represent the list of scores from the second competition, after they are sorted and "hacked"


Input:
4
4 1 3 2
1 8 4 2

Output:
8 1 4 2
Explanation, after Z's sorting the scores will be: 8 4 2 1, and then we apply hackers exchanges, and obtain 8 1 4 2


Input:
3
10 20 30
8 4 7

Output:
4 7 8
Explanation, after Z's sorting the scores will be: 8 7 4. We see that the hackers apply such a set of exchanges that the array ends up being sorted in an increasing order.

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.