You are given a 2-D matrix of size , its elements are integers. We will assume that the rows of the matrix are numbered from top to bottom from to , the columns are numbered from left to right from to . We will denote the element on the intersecting of the -th row and the -th column as .
Find the maximum possible value , such that:
Input format
Output format
Print the value of .
Constraints
If , all the elements in row and column satisfy the given conditions. It can be proved that cannot be greater than .