<garvit244>317_1.py
def bfs(grid, distance_reach_map, row, col):
    if(row < 0 or row > len(grid) or col < 0 or col > len(grid[0])):
        return
    queue = [[row, col]]
    qdist = [1]
    
    direction = [[-1, 0], [0, 1], [1, 0], [0, -1]]
    while queue:
        x, y = queue.pop(0)
        curr_dist = qdist.pop(0)
    
        for dx, dy in direction:
            new_x, new_y = x+dx, y+dy
            if((0 <= new_x < len(grid)) and (0 <= new_y < len(grid[0])) and grid[new_x][new_y] == 0):
                grid[new_x][new_y] = -1
                queue.append([new_x, new_y])
    
                
                temp = distance_reach_map[new_x][new_y]
                dist, reach = temp[0], temp[1]
                dist += curr_dist
                reach += 1
                distance_reach_map[new_x][new_y] = [dist, reach]
                qdist.append(curr_dist+1)
    
    for row in range(len(grid)):
        for col in range(len(grid[0])):
            if grid[row][col] == -1:
                grid[row][col] =0
def sample_funcname ( var_0 , var_1 , var_2 , var_3 ) :
    if ( var_2 < 0 or var_2 > len ( var_0 ) or var_3 < 0 or var_3 > len ( var_0 [ 0 ] ) ) :
        return
    var_6 = [ [ var_2 , var_3 ] ]
    var_8 = [ 1 ]
    var_9 = [ [ - 1 , 0 ] , [ 0 , 1 ] , [ 1 , 0 ] , [ 0 , - 1 ] ]
    while var_6 :
        var_11 , var_12 = var_6.pop ( 0 )
        var_13 = var_8.pop ( 0 )
        for var_14 , var_15 in var_9 :
            var_16 , var_17 = var_11 + var_14 , var_12 + var_15
            if ( ( 0 <= var_16 < len ( var_0 ) ) and ( 0 <= var_17 < len ( var_0 [ 0 ] ) ) and var_0 [ var_16 ] [ var_17 ] == 0 ) :
                var_0 [ var_16 ] [ var_17 ] = - 1
                var_6.append ( [ var_16 , var_17 ] )
                var_19 = var_1 [ var_16 ] [ var_17 ]
                var_20 , var_21 = var_19 [ 0 ] , var_19 [ 1 ]
                var_20 += var_13
                var_21 += 1
                var_1 [ var_16 ] [ var_17 ] = [ var_20 , var_21 ]
                var_8.append ( var_13 + 1 )
    for var_2 in range ( len ( var_0 ) ) :
        for var_3 in range ( len ( var_0 [ 0 ] ) ) :
            if var_0 [ var_2 ] [ var_3 ] == - 1 :
                var_0 [ var_2 ] [ var_3 ] = 0
