Festival Decorating
면접 대비시간 제한9초메모리 제한2048 MB
각 질의 거리 d마다 x_u+d 위치에 다른 색 램프가 있는 가장 작은 램프 번호 u를 구한다.
문제
To celebrate the coming winter festival in Byteland, the main street, which can be regarded as the x-axis, is decorated with colorful lamps, labeled by . The x-coordinate of the -th lamp is , and the color of the -th lamp is . No two lamps share the same x-coordinate.
You will be given queries. In the -th query, you will be given an integer (), and you need to find the lamp () with the minimum index such that there is another lamp located at and the color of that lamp is different from , or determine it is impossible to find such . Your answer is considered correct if its absolute or relative error does not exceed .
입력
The first line of the input contains two integers and () denoting the number of lamps and the number of queries.
Each of the next lines contains two integers and (, ) denoting the x-coordinate and the color of the -th lamp. It is guaranteed that no two lamps share the same x-coordinate.
Each of the next lines contains a single integer () denoting the -th query.
출력
For each query, print a line containing a single number: the minimum index you found. If it is impossible to find such , print instead.
Your answer is considered correct if its absolute or relative error does not exceed . Note that this means you can output a non-integer as well.
Formally, let your answer be , and the jury's answer be . Your answer is accepted if and only if: