← 返回 cisco 的题目列表Find the Element in a Matrix
类型:online_judge
cisco
Write a function to find an element in a matrix that is the largest in its row and smallest in its column.
Input: The first line of input consists of two space-separated integers: matrix_row and matrix_col, denoting the number of rows and columns in the matrix. The next matrix_row lines each contain matrix_col non-negative integers.
Output: Print the element if found, otherwise print -1.
Constraints:
1 ≤ N, M ≤ 1000
Each element in the matrix is a non-negative integer.
Example
Input
3 3
1 2 3
4 5 6
7 8 9