Time limit: 1.00 s Memory limit: 512 MB
There are
Each customer announces the maximum price they are willing to pay for a ticket, and after this, they will get a ticket with the nearest possible price such that it does not exceed the maximum price.
Input
The first input line contains integers
The next line contains
The last line contains
Output
Print, for each customer, the price that they will pay for their ticket. After this, the ticket cannot be purchased again.
If a customer cannot get any ticket, print
Constraints
- 1
$\le$ $n$ ,$m$ $\le$ 2$\cdot$ $10^{5}$ - 1
$\le$ $h_i$ ,$t_i$ $\le$ $10^{9}$
Example
Input:
5 3
5 3 7 8 5
4 8 3
Output:
3
8
-1