Loading...
Remove It
Time: 1 s
Memory: 125 MB
You are given a list of integers \(A\) of length \(N\). Also with \(N\) queries. In every query you will be given an integer \(x\). Print What is the integer currently is in \(A_x\) and erase \(A_x\) from the list. 
Input
The first line of the input contains two integers \(N\). Denoting the lenght of the list.
The Second line contains N integers of list. 
The third line contains N integers which will be the queries.
Constraint
\(1 \le N \le 2 \times 10^5\)
\(1 \le A_i \le 10^9\)
Output
Print N integers in a single line where the \(ith\) integer is the result of \(ith \) query.
Examples
Input
Output
10
2 4 9 7 3 1 1 2 6 4
1 7 6 6 6 3 1 2 1 1
2 2 1 6 4 7 4 3 9 1
Problem Info
Problem ID 320
Time Limit 1000 ms
Memory Limit 128000 KB
Moderators Royboy01 , raj3100
Statistics
Submit
You need to Login or Registration for submit your solution