class Solution(object):
    def isToeplitzMatrix(self, matrix):
        """
        :type matrix: List[List[int]]
        :rtype: bool
        """
        group={}
        for r,row in enumerate(matrix):
            for c,val in enumerate(row):
                if r-c not in group:
                    group[r-c]=val
                elif group[r-c]!=val:
                    return False
        return True
solution=Solution()
matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
print(solution.isToeplitzMatrix(matrix))
