Paged Metrics Table
A metrics store records sample timestamps (in microseconds) and keeps them in pages. The pages form a table of R rows and C columns: each row is sorted in increasing order, and every row starts with a timestamp greater than the last timestamp of the row above it. All timestamps are distinct.
A dashboard sends q lookups. For each timestamp x, report the row and column of the cell holding x, or say that x is not stored.
Input
The first line contains two integers R and C (1 ≤ R, C and R·C ≤ 10^6).
Each of the next R lines contains C integers, the timestamps of one row (0 ≤ t ≤ 10^12). Each row is strictly increasing, and the first value of each row is greater than the last value of the previous row.
The next line contains q (1 ≤ q ≤ 2·10^5). Each of the next q lines contains one lookup x (0 ≤ x ≤ 10^12).
Timestamps can exceed 2^31, so use 64-bit integers.
Output
For each lookup, print one line: the row and the column of the cell holding x (both 1-based, separated by a space), or -1 if x is not in the table.
Notes
In the first example, 21 is in row 2, column 3. The value 13 falls between the end of row 1 and the start of row 2, and 60 is past the last cell, so both print -1.
In the second example the table has a single column, and some timestamps don't fit in a 32-bit integer.