public static int cal(int i, int j, int cur) {
		if (min[i][j] != 0)
			return min[i][j];
		int up, down, left, right;
		up = down = left = right = 0;
		if (i - 1 >= 0 && m[i][j] < m[i - 1][j])
			up = cal(i - 1, j, cur + 1);
		if (j - 1 >= 0 && m[i][j] < m[i][j - 1])
			left = cal(i, j - 1, cur + 1);
		if (i + 1 < rows && m[i][j] < m[i + 1][j])
			down = cal(i + 1, j, cur + 1);
		if (j + 1 < cols && m[i][j] < m[i][j + 1])
			right = cal(i, j + 1, cur + 1);
		return (min[i][j] = 1+max(up, down, left, right));
	}