~/algor $ cat problems/qidiruv-saralangan-jadval
Search in a sorted table
A table with $n$ rows and $m$ columns is given. Read row by row (the first row from left to right, then the second row and so on), its numbers are strictly increasing. Each of $q$ queries gives an integer $x$: in which row and which column of the table is it? If it is not in the table, print $-1$.
Input
The first line contains three positive integers: $n$, $m$ and $q$.
Each of the next $n$ lines contains $m$ integers — the table.
Each of the next $q$ lines contains one integer $x$.
Output
For each query on a separate line: the row and column numbers, or $-1$.
Note
$1 \le n \cdot m \le 10^{5}$
$1 \le q \le 10^{5}$
the numbers of the table and $x$ do not exceed $10^{9}$ in absolute value
Examples
3 4 3 1 3 5 7 10 11 16 20 23 30 34 60 3 16 13
1 2 2 3 -1
1 1 2 5 5 -5
1 1 -1