


import os
def   _UpperCamelCase				(						lowerCAmelCase_ = "input.txt"   )						->int:

   with open(os.path.join(os.path.dirname(lowerCAmelCase_   )  ,						lowerCAmelCase_   )   ) as input_file:
      UpperCAmelCase							=     [
          [int(lowerCAmelCase_   ) for element in line.split(""","""   )]
          for line in input_file.readlines()
      ]

   UpperCAmelCase							=     len(lowerCAmelCase_   )
   UpperCAmelCase							=     len(matrix[0]   )

   UpperCAmelCase							=     [[-1 for _ in range(lowerCAmelCase_   )] for _ in range(lowerCAmelCase_   )]
   for i in range(lowerCAmelCase_   ):
      UpperCAmelCase							=     matrix[i][0]

   for j in range(1  ,						lowerCAmelCase_   ):
      for i in range(lowerCAmelCase_   ):
         UpperCAmelCase							=     minimal_path_sums[i][j - 1] + matrix[i][j]

      for i in range(1  ,						lowerCAmelCase_   ):
         UpperCAmelCase							=     min(
             minimal_path_sums[i][j]  ,						minimal_path_sums[i - 1][j] + matrix[i][j]   )

      for i in range(rows - 2  ,						-1  ,						-1   ):
         UpperCAmelCase							=     min(
             minimal_path_sums[i][j]  ,						minimal_path_sums[i + 1][j] + matrix[i][j]   )

   return min(minimal_path_sums_row[-1] for minimal_path_sums_row in minimal_path_sums   )


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







from __future__ import annotations
def   _UpperCamelCase				(						lowerCAmelCase_   )						->None:
   create_state_space_tree(lowerCAmelCase_  ,						[]  ,						0  ,						[0 for i in range(len(lowerCAmelCase_   )   )]   )
def   _UpperCamelCase				(						lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_  ,						)						->None:

   if index == len(lowerCAmelCase_   ):
      print(lowerCAmelCase_   )
      return

   for i in range(len(lowerCAmelCase_   )   ):
      if not index_used[i]:
         current_sequence.append(sequence[i]   )
         UpperCAmelCase							=     True
         create_state_space_tree(lowerCAmelCase_  ,						lowerCAmelCase_  ,						index + 1  ,						lowerCAmelCase_   )
         current_sequence.pop()
         UpperCAmelCase							=     False
__a     =			[3, 1, 2, 4]
generate_all_permutations(sequence)

__a     =			["A", "B", "C"]







generate_all_permutations(sequence_a)



