def fill_in_word(grid, word, position, direction):
    """Create and return a new grid (a list of lists) based on the grid
    given in the arguments, but with the given word inserted according
    to position and direction.
        - direction: is either 'down' or 'across'.
        - position: the coordinates of the first letter of the word in the grid.
    *This function may modify its grid argument!*
    """
    x = position[0]
    y = position[1]
    if direction == 'across':
        for i in range(len(word)):
            grid[x][y + i] = word[i]
    else:
        for i in range(len(word)):
            grid[x + i][y] = word[i]
    return grid