def flash_octopus(
    row: int, col: int, grid: list[list[int]]
) -> tuple[list[list[int]], int]:
    """Flashes single occtopus. (recursively)

    If the flash of an occtopus causes another occtopus to flash the function
    is called recursivly.
    The energy level of the flashed occtopus is reset to -1 to prevent multiple
    flashing.

    Args:
        row (int): row of flashing occtopus
        col (int): column of flashing occtopus
        grid (list[list[int]]): energy grid

    Returns:
        list[list[int]]: updated energy grid
        int:    number of flashes

    Examples:
        >>> flash_octopus(1,1,[[1,1,1],[1,10,1],[1,1,1]])
        ([[2, 2, 2], [2, -1, 2], [2, 2, 2]], 1)
        >>> flash_octopus(1,1,[[9,1,9],[6,10,8],[8,9,7]])
        ([[-1, 6, -1], [-1, -1, -1], [-1, -1, -1]], 8)
    """
    num_row = len(grid)
    num_col = len(grid[0])
    flashes = 1
    grid[row][col] = -1
    for delta_row in [-1, 0, 1]:
        for delta_col in [-1, 0, 1]:
            row_adjacent = row + delta_row
            col_adjacent = col + delta_col
            if (
                0 <= row_adjacent < num_row
                and 0 <= col_adjacent < num_col
                and grid[row_adjacent][col_adjacent] != -1
            ):
                grid[row_adjacent][col_adjacent] += 1
                if grid[row_adjacent][col_adjacent] >= 10:
                    grid, flashes_child = flash_octopus(
                        row_adjacent, col_adjacent, grid
                    )
                    flashes += flashes_child
    return grid, flashes