#Lutece0542. Kawashiro Nitori's Cucumber Detector
Kawashiro Nitori's Cucumber Detector
Migrated from Lutece 542 Kawashiro Nitori's Cucumber Detector
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
As any other Kappa(河童), Kawashiro Nitori loves cucumbers. So she invented a great cucumber detector to detect the cucumbers underground within the range of R. (You mean the cucumbers don't grow undergrond? In Gensoukyou, never be tied to common sense.) And detector divides the cucumbers into levels, the level is the best, and level is the worst. Specially, level means there's no cucumber at ths position.
In this problem, let's assume there's cucumbers grow in a line and their position are labeled from to . Given all the information about the cucumbers, can you tell Nitori the best cucumber among the detector's range at some particular position? See more information at the sample.
Input
There is only one integer in the first line.
Then parts follow, each begins with a line with integers , (, , ) indicating the number of cucumbers, the number of the position to be detected and the working range of the detector. And the next line would be integers, the integer means the level of cucumber is . And the final line of the part would be integers, showing the position to be detected.
Output
For each part, output a line with numbers, which shows the best cucumber that could be detected at this position.
There is a blank after each number.
Samples
1
6 6 1
2 0 0 0 0 4
1 2 3 4 5 6
2 2 0 0 4 4
Note
Since so many test cases here, an algorithm with time complexity will not get Accepted.
Resources
Sakuya