binary search for 2-D matrix