Problems
Black Box
Black Box
Our Black Box represents a primitive database. It can save an integer array and has a special \textbf{i} variable. At the initial moment Black Box is empty and \textbf{i} equals \textbf{0}. This Black Box processes a sequence of commands (transactions). There are two types of transactions:
\textbf{ADD}(\textbf{x}): put element \textbf{x} into Black Box;
\textbf{GET}: increase \textbf{i} by \textbf{1} and give an \textbf{i}-minimum out of all integers containing in the Black Box.
Keep in mind that \textbf{i}-minimum is a number located at \textbf{i}-th place after Black Box elements sorting by non-descending.
Consider the Example:
It is required to work out an efficient algorithm which treats a given sequence of transactions. The maximum number of \textbf{ADD} and \textbf{GET} transactions: \textbf{30000} of each type.
Let us describe the sequence of transactions by two integer arrays:
\textbf{1. A}(\textbf{1}), \textbf{A}(\textbf{2}), ..., \textbf{A}(\textbf{m}): a sequence of elements which are being included into Black Box. A values are integers not exceeding \textbf{2 000 000 000} by their absolute value, \textbf{m} ≤ \textbf{30000}. For the Example we have \textbf{A} = (\textbf{3}, \textbf{1}, \textbf{-4}, \textbf{2}, \textbf{8}, \textbf{-1000}, \textbf{2}).
\textbf{2.} \textbf{u}(\textbf{1}), \textbf{u}(\textbf{2}), ..., \textbf{u}(\textbf{n}): a sequence setting a number of elements which are being included into Black Box at the moment of first, second, ... and \textbf{n}-transaction \textbf{GET}. For the Example we have \textbf{u} = (\textbf{1}, \textbf{2}, \textbf{6}, \textbf{6}).
The Black Box algorithm supposes that natural number sequence \textbf{u}(\textbf{1}), \textbf{u}(\textbf{2}), ..., \textbf{u}(\textbf{n}) is sorted in non-descending order, \textbf{n} ≤ \textbf{m}, and for each \textbf{p} (\textbf{1} ≤ \textbf{p} ≤ \textbf{n}) an inequality \textbf{p} ≤ \textbf{u}(\textbf{p}) ≤ \textbf{m} is valid. It follows from the fact that for the \textbf{p}-element of our \textbf{u} sequence we perform a \textbf{GET} transaction giving \textbf{p}-minimum number from our \textbf{A}(\textbf{1}), \textbf{A}(\textbf{2}), ..., \textbf{A}(\textbf{u}(\textbf{p})) sequence.
\InputFile
The input dataset contains numbers: \textbf{m}, \textbf{n}, \textbf{A}(\textbf{1}), \textbf{A}(\textbf{2}), ..., \textbf{A}(\textbf{m}), \textbf{u}(\textbf{1}), \textbf{u}(\textbf{2}), ..., \textbf{u}(\textbf{n}). All numbers are divided by spaces and (or) carriage return characters.
\OutputFile
Print the Black Box answers sequence for a given sequence of transactions. Each number must be printed in the separate line.
Input example #1
7 4 3 1 -4 2 8 -1000 2 1 2 6 6
Output example #1
3 3 1 2