class Matrix:
    def __init__(self, rows):
        self.rows = rows
        self.row_count = len(rows)
        self.col_count = len(rows[0])
    
    def is_valid_cell(self, row, col):
        return (
            row >= 0 and row < self.row_count and
            col >= 0 and col < self.col_count
        )
    
    def __repr__(self):
        result = ''
        for row in self.rows:
            result += str(row) + '\n'
        return result

    def __getitem__(self, index):
        return self.rows[index]
    
    def __setitem__(self, index, value):
        self.rows[index] = value