~/algor $ cat problems/qidiruv-sonning-orinlari
Positions in a sorted array
$n$ integers sorted in non-decreasing order, $a_{1} \le a_{2} \le \dots \le a_{n}$, and $q$ queries are given. Each query gives an integer $x$: at which positions does $x$ occur in the array for the first and for the last time? Positions are numbered from $1$.
Input
The first line contains two positive integers: $n$ and $q$. The second line contains $n$ integers $a_{i}$ separated by spaces. Each of the next $q$ lines contains one integer $x$.
Output
$q$ lines: for each query two numbers separated by a space — the first and the last position, or $-1$ if $x$ is not in the array.
Note
$1 \le n, q \le 10^{5}$
$-10^{9} \le a_{i}, x \le 10^{9}$
$a_{1} \le a_{2} \le \dots \le a_{n}$
Examples
7 3 1 2 2 2 5 7 7 2 7 4
2 4 6 7 -1
1 2 5 5 6
1 1 -1