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 \le i \le 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 \(i^{th}\) integer denotes \(A[i]\). The next line too contains N space separated integers, where the \(i^{th}\) integer on this line denotes \(B[i]\).
Output Format :
Print N space separated integers according to those mentioned in the problem statement.
Constraints :
\( 1 \le N \le 200,000 \)
\( 1 \le A[i], B[i] \le 10^9 \)