


import os


def 		lowercase_  (     _UpperCamelCase = "matrix.txt"  ):


			'''simple docstring'''







			with open(os.path.join(os.path.dirname(_UpperCamelCase  )       ,			_UpperCamelCase  )  ) as in_file:
						__lowercase 					=   in_file.read()

			__lowercase 					=   [[int(_UpperCamelCase  ) for cell in row.split(''','''  )] for row in data.strip().splitlines()]
			__lowercase 					=   [[0 for cell in row] for row in grid]
			__lowercase 					=   len(grid[0]  )

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

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

			return dp[-1][-1]


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






import unittest

from knapsack import knapsack as k
class 	lowerCamelCase_       (				unittest.TestCase				):



					'''simple docstring'''







					def A      (				self						)   ->			Optional[Any]:







								'''simple docstring'''

								__lowercase 					=   0
								__lowercase 					=   [0]
								__lowercase 					=   [0]
								__lowercase 					=   len(snake_case_						)
								self.assertEqual(k.knapsack(snake_case_ ,       snake_case_ ,       snake_case_ ,       snake_case_						) ,       0						)

								__lowercase 					=   [6_0]
								__lowercase 					=   [1_0]
								__lowercase 					=   len(snake_case_						)
								self.assertEqual(k.knapsack(snake_case_ ,       snake_case_ ,       snake_case_ ,       snake_case_						) ,       0						)






					def A      (				self						)   ->			Tuple:







								'''simple docstring'''

								__lowercase 					=   3
								__lowercase 					=   [1, 2, 3]
								__lowercase 					=   [3, 2, 1]
								__lowercase 					=   len(snake_case_						)
								self.assertEqual(k.knapsack(snake_case_ ,       snake_case_ ,       snake_case_ ,       snake_case_						) ,       5						)






					def A      (				self						)   ->			str:







								'''simple docstring'''

								__lowercase 					=   5_0
								__lowercase 					=   [6_0, 1_0_0, 1_2_0]
								__lowercase 					=   [1_0, 2_0, 3_0]
								__lowercase 					=   len(snake_case_						)
								self.assertEqual(k.knapsack(snake_case_ ,       snake_case_ ,       snake_case_ ,       snake_case_						) ,       2_2_0						)


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


