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