```
class Solution:
# @param {integer[][]} matrix
# @param {integer} target
# @return {boolean}
def searchMatrix(self, matrix, target):
left,right=0,len(matrix)*len(matrix[0])-1
while left<=right:
mid=(left+right)/2
tmp=matrix[mid/len(matrix[0])][mid%len(matrix[0])]
if target<tmp:
right=mid-1
elif target>tmp:
left=mid+1
else:
return True
return False
```