Festival Decorating
Time limit9sMemory limit2048 MB
For each distance d, find the lowest-index lamp that has a lamp at x plus d with a different color, or print 0 if none exists.
Statement
To celebrate the coming winter festival in Byteland, the main street is decorated with colorful lamps. The street can be regarded as the x-axis. The lamps are labeled . The -th lamp is at x-coordinate and has color . No two lamps share the same x-coordinate.
You will be given queries. In the -th query, you are given an integer (). Find the lamp () with the minimum index such that another lamp is located at and its color differs from . If no such exists, the answer is impossible to find.
Input
The first line contains two integers and (). Each of the next lines contains and (, ). Each of the next lines contains one integer .
Output
For each query, print one line containing the minimum index . If no such exists, print . An answer is correct if its absolute or relative error does not exceed . That is, for your answer and the jury's answer , the answer is accepted when . You may print a non-integer.