# A list of lists as Vibe takes it (D188, VIBE-15): displays and comprehensions of rows,
# `[0] * k`, rows appended, an element read and replaced, a row grown in place, through a
# name and in a `for` over the rows, a row's length and a copy of a row. Its output is
# CPython's.


def total(grid: list[list[int]]) -> int:
    t = 0
    for row in grid:
        for x in row:
            if 0 <= x <= 1000 and 0 <= t <= 1000000:
                t += x
    return t


def main() -> None:
    grid: list[list[int]] = [[1, 2], [3, 4]]
    row: list[int] = [5, 6, 7]
    grid.append(row)
    grid[0][1] = 20
    grid[1].append(9)
    first = grid[0]
    print(len(grid), len(grid[1]), grid[0][1], grid[2][2], first[0], total(grid))
    board: list[list[int]] = [[0] * 3 for _ in range(2)]
    board[1][2] = 7
    print(board[1][2], board[0][2])
    for line in board:
        line.append(1)
        if len(line) > 10:
            line.append(2)
    print(len(board), len(board[0]), board[1][3], board[0][2], total(board))


if __name__ == "__main__":
    main()
