Ranald the cat is implementing a ballot system to select C students to attend CS3233. However, he doesn't know how to implement it!
So, if you code it for him, you should stand a higher chance in going to attend CS3233.
Ballot System Description
Each student gets to choose his/her unique ballot number from 1 to 1000000000. Furthermore, there will be N students labelled from 1 to N.
In order to select a student, Ranald chooses a number from 1 to 1000000000 as well. The student whose ballot number is the closest to the number Ranald selects will get to go for CS3233! In the event that 2 students are concurrently closest to the number selected, the student with a lower ballot number will get to go! Once a student is selected, his ballot ticket will be removed from the ballot system.
Subtask 1 (20%): 0 < C ≤ N ≤ 100.
Subtask 2 (30%): 0 < C ≤ N ≤ 1000.
Subtask 3 (50%): 0 < C ≤ N ≤ 100000.
The first line of input consists of 2 integers, N followed by C.
The following line will consist of N integers, which are the ballot number of the students. The ith number in this line is the ballot number of the ith student (student with label i).
The following line will consist of C integers, which are the numbers that Ranald picks. These numbers are provided in chronological order, where the first number is selected first.
Output C lines with 1 integer each. These C integers should denote which students will get to attend CS3233 (print their student labels) in any order.
Sample Input 1
10 13 14 9 15
12 12 12
Sample Output 1
Explanation for Sample Output 1
When Ranald chose the number '12', the ballot number of '13' is the closest to 12. Therefore, the corresponding student '2' gets selected for CS3233.
When Ranald chose the number '12' again, number '10' and '14' are of equal distance to 12. Therefore, the student with the lower ballot number ('10') will get to go for CS3233. (This is student '1').
When Ranald chose the number '12' yet again, '14' is the closest to 12. Therefore, the corresponding student '3' gets selected for CS3233. This is because the ballot numbers of '10' and '13' have already been removed from the system.
Sample Input 2
10 13 14 9 15
12 12 12
Sample Output 2
Explanation for Sample Output 2
Same as above, but in a different order of output.