





import os




def     a__ (					lowercase__ = "matrix.txt"  ):






   '''simple docstring'''






   with open(os.path.join(os.path.dirname(lowercase__  )  ,    lowercase__  )  ) as in_file:
      UpperCAmelCase_											=in_file.read()

   UpperCAmelCase_											=[[int(lowercase__  ) for cell in row.split(","  )] for row in data.strip().splitlines()]
   UpperCAmelCase_											=[[0 for cell in row] for row in grid]
   UpperCAmelCase_											=len(grid[0]  )

   UpperCAmelCase_											=[[0 for i in range(lowercase__  )] for j in range(lowercase__  )]
   UpperCAmelCase_											=grid[0][0]
   for i in range(1  ,    lowercase__  ):
      UpperCAmelCase_											=grid[0][i] + dp[0][i - 1]
   for i in range(1  ,    lowercase__  ):
      UpperCAmelCase_											=grid[i][0] + dp[i - 1][0]

   for i in range(1  ,    lowercase__  ):
      for j in range(1  ,    lowercase__  ):
         UpperCAmelCase_											=grid[i][j] + min(dp[i - 1][j]  ,    dp[i][j - 1]  )

   return dp[-1][-1]


if __name__ == "__main__":
     print(f"""{solution() = }""")











from __future__ import annotations




def     a__ (					lowercase__  ,    lowercase__  ):






   '''simple docstring'''






   UpperCAmelCase_						,       UpperCAmelCase_											=set(lowercase__  ), [start]

   while stack:
      UpperCAmelCase_											=stack.pop()
      explored.add(lowercase__  )
      # Differences from BFS:
      # 1) pop last element instead of first one
      # 2) add adjacent elements to stack without exploring them
      for adj in reversed(graph[v]  ):
         if adj not in explored:
            stack.append(lowercase__  )
   return explored


__lowercase  :   Dict						      ={
    """A""": ["""B""", """C""", """D"""],
    """B""": ["""A""", """D""", """E"""],
    """C""": ["""A""", """F"""],
    """D""": ["""B""", """D"""],
    """E""": ["""B""", """F"""],
    """F""": ["""C""", """E""", """G"""],
    """G""": ["""F"""],
}

if __name__ == "__main__":
     import doctest

     doctest.testmod()
     print(depth_first_search(G, """A"""))




