def check_rectangle(matrix):
    """checks if a matrix is a rectangle
    """
    prevRowSize = -1
    for row in matrix:
        if prevRowSize != -1 and prevRowSize != len(row):
            return False
        prevRowSize = len(row)
    return True