IntermediateRating 1400
Search a Sorted Grid
Each row and each column is sorted increasingly. Print the (row col) of x (1-based; any occurrence found by the staircase search from the top-right), or -1.
Input
r c x, then r lines.
Output
Two numbers or -1.
Sample 1
Input
3 3 5 1 4 7 2 5 8 3 6 9
Output
2 2
Sample 2
Input
3 3 10 1 4 7 2 5 8 3 6 9
Output
-1
Output appears here