A sorted array of $N$ integers (duplicates allowed) is given, then $Q$ queries. For each value $K$ print the 1-based position of its first occurrence, or -1 if $K$ is not present.
Input
Line 1: $N$ $Q$. Line 2: $N$ sorted integers. Next $Q$ lines: a value each.
Output
Print the first-occurrence position (or -1) for each query.
Example 1
Input
10 4 1 2 2 2 5 5 7 9 9 10 2 5 9 3
Output
2 5 8 -1
Example 2
Input
7 5 -5 -5 -1 0 0 0 8 -5 0 8 7 -10
Output
1 4 7 -1 -1
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.