

"""simple docstring"""




import os





def       lowercase__						(       snake_case_   :Optional[int] = "input.txt"    ):

	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() = }""")




class     __UpperCAmelCase							:


     """simple docstring"""


     def __init__(	self  ,       __A    ):
        __a					=  set_counts
        __a					=  max(__A    )
        __a					=  len(__A    )
        __a					=  [1] * num_sets
        __a					=  list(range(__A    )    )


     def 	snake_case_  (	self  ,       __A  ,       __A    ):
        __a					=  self.get_parent(__A    )
        __a					=  self.get_parent(__A    )

        if src_parent == dst_parent:
           return False

        if self.ranks[dst_parent] >= self.ranks[src_parent]:
           self.set_counts[dst_parent] += self.set_counts[src_parent]
           __a					=  0
           __a					=  dst_parent
           if self.ranks[dst_parent] == self.ranks[src_parent]:
              self.ranks[dst_parent] += 1
           __a					=  self.set_counts[dst_parent]
        else:
           self.set_counts[src_parent] += self.set_counts[dst_parent]
           __a					=  0
           __a					=  src_parent
           __a					=  self.set_counts[src_parent]

        __a					=  max(self.max_set  ,       __A    )
        return True


     def 	snake_case_  (	self  ,       __A    ):
        if self.parents[disj_set] == disj_set:
           return disj_set
        __a					=  self.get_parent(self.parents[disj_set]    )
        return self.parents[disj_set]



