class Solution(object):
    def searchMatrix(self, matrix, target):
        """
        :type matrix: List[List[int]]
        :type target: int
        :rtype: bool
        """
        m = len(matrix)
        if m > 0:
            n = len(matrix[0])
            if n > 0 :
                for i in range(m):
                    if matrix[i][0] <= target <= matrix[i][n-1]:
                        for j in range(n):
                            if matrix[i][j] == target:
                                return True
        return False