public static boolean searchMatrix1(ArrayList<ArrayList<Integer>> matrix, int target) {
		// write your code
		ArrayList<ArrayList<Integer>>A=matrix;
		if (A==null||A.size()==0)
			return false;
		int m=A.size(), n=A.get(0).size();
		int t=target, l=0, r=m*n-1;
		while (l<=r) {
			int mid=l+(r-l)/2;
			int y=mid/n, x=mid%n;
			int a=A.get(y).get(x);
			if (a==t) {
				return true;
			} else if (a<t) {
				l=mid+1;
			} else {
				r=mid-1;
			}
		}
		return false;
	}