



'''simple docstring'''

import os







def 						__UpperCamelCase				(							_lowercase = "input.txt"					) ->			int:

	with open(os.path.join(os.path.dirname(_lowercase					),				_lowercase					)					) as input_file:
		_lowercase					:       Optional[Any]       =		[
		    [int(_lowercase					) for element in line.split(','					)]
		    for line in input_file.readlines()
		]

	_lowercase					:       Any       =		len(_lowercase					)
	_lowercase					:       Dict       =		len(matrix[0]					)

	_lowercase					:       Tuple       =		[[-1 for _ in range(_lowercase					)] for _ in range(_lowercase					)]
	for i in range(_lowercase					):
		_lowercase					:       Union[str, Any]       =		matrix[i][0]

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

		for i in range(1,				_lowercase					):
			_lowercase					:       List[str]       =		min(
			    minimal_path_sums[i][j],				minimal_path_sums[i - 1][j] + matrix[i][j]					)

		for i in range(rows - 2,				-1,				-1					):
			_lowercase					:       Optional[Any]       =		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() = }''')





'''simple docstring'''

import unittest

from knapsack import greedy_knapsack as kp



class 		lowerCamelCase__      (						unittest.TestCase     ):




					'''simple docstring'''



					def 						__UpperCAmelCase     (  self				:	int					)  ->       Any:



						'''simple docstring'''





						_lowercase					:       List[Any]       =		[10, 20, 30, 40, 50, 60]
						_lowercase					:       Tuple       =		[2, 4, 6, 8, 10, 12]
						_lowercase					:       Optional[Any]       =		100
						self.assertEqual(kp.calc_profit(UpperCamelCase_     ,  UpperCamelCase_     ,  UpperCamelCase_					)     ,  210					)




					def 						__UpperCAmelCase     (  self				:	int					)  ->       int:



						'''simple docstring'''





						self.assertRaisesRegex(UpperCamelCase_     ,  'max_weight must greater than zero.'					)




					def 						__UpperCAmelCase     (  self				:	Dict					)  ->       Optional[Any]:



						'''simple docstring'''





						self.assertRaisesRegex(UpperCamelCase_     ,  'Weight can not be negative.'					)




					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       Optional[Any]:



						'''simple docstring'''





						self.assertRaisesRegex(UpperCamelCase_     ,  'Profit can not be negative.'					)




					def 						__UpperCAmelCase     (  self				:	int					)  ->       List[str]:



						'''simple docstring'''





						self.assertRaisesRegex(UpperCamelCase_     ,  'max_weight must greater than zero.'					)




					def 						__UpperCAmelCase     (  self				:	int					)  ->       List[Any]:



						'''simple docstring'''





						self.assertRaisesRegex(
						    UpperCamelCase_     ,  'The length of profit and weight must be same.'					)


if __name__ == "__main__":
		unittest.main()
