LearnPy Hub
← Arena
IntermediateRating 1200

Saddle Points

Print every value that is the smallest in its row and the largest in its column, in increasing order, or -1. All values are distinct.

Input

r c, then r lines.

Output

One line.

Sample 1

Input
3 3
3 7 8
9 11 13
15 16 17
Output
15

Sample 2

Input
2 2
1 2
3 4
Output
3
solution.py
Output appears here
Saddle Points · Python Arena problem · LearnPy Hub