John is playing a game on a square matrix of dimensions . The rows and the columns of the matrix are numbered from to . Cell is the cell located in the -th column of the -th row. The matrix contains integers in each cell, specifically, the number written in cell is .
The game consists of a sequence of moves of the form:
- Select a cell .
- The score of the move is the value written in cell .
- Remove the -th row and the -th column from the matrix.
- Repeat the same process until the matrix becomes empty.
The score of the game is defined as the minimum of the scores of the moves. John asks you to determine the maximum possible score of a game that can be played on the given matrix.
Input data
The first line of input contains , the number of rows and columns of the matrix.
Each of the next lines contains numbers. The -th number in the -th line is the value , i.e., the number written in cell .
Output data
Output a single number, representing the maximal possible score achievable in a game.
Constraints and Clarifications
- .
- for each and .
# | Score | Restrictions |
---|---|---|
1 | 0 | Examples. |
2 | 10 | . |
3 | 30 | , for each and . |
4 | 45 | . |
5 | 15 | No additional limitations. |
Example
stdin
3
8 0 7
5 6 9
1 7 9
stdout
7
Explanation
In the sample case, one possible optimal way of playing the game is as follows:
- First, select cell with the value , and remove the first row and the first column. The matrix becomes this:
- Then, select the cell of this new matrix with the value , and remove the second row and the first column. The matrix will consist of a single value .
- Finally, select the single value in the matrix, and remove it so that the matrix becomes empty.
The score of the game is the minimum of the scores of the moves, which is .