Stevie G is one of the greatest ever players to have played football, and he's going to be the one who recites all problems to you today . Let's have a look at him :
Now, he is a true admirer of mathematical geniuses like you. So he has a series of programming problems, among which the first one is :
You have been given 2 integer arrays A and B each of size N. Now we call a pair of indices (i,j) connected, if i=j or A[i]=A[j] .
Now, for each index i in the array A where 1≤i≤N, you need to find the maximum B[j] such that indices i and j are connected. Can you do it ?
Input Format :
The first line contains a single integer N.
The next line contains N space separated integers, where the ith integer denotes A[i]. The next line too contains N space separated integers, where the ith integer on this line denotes B[i].
Output Format :
Print N space separated integers according to those mentioned in the problem statement.
Constraints :
1≤N≤200,000
1≤A[i],B[i]≤109
Indices 1 and 5 are connected. Therefore the answer for indices 1 and 5 will be whichever has a larger value of B[].
Similarly, indices 2 and 4 are connected.
Index 3 is not connected to any other index.